History

V4L/DVB: IR/imon: remove bad ir_input_dev use

The ir_input_dev gets filled in by __ir_input_register, the one allocated in imon_init_idev was being overwritten by the correct one shortly after it was initialized (ultimately resulting in a memory leak). Additionally, there was an ill-advised memcpy into that extraneous ir_input_dev which gets fixed by this. Ill-advised memcpy pointed out by Dmitry Torokhov, bad usage of ir_input_dev pointed out by Maxim Levitsky.

Jarod Wilson committed 16 years ago

Commit da48db61 parent 20cd1951 file · +0 −15Browse files

Unified · Split

drivers/media/IR/imon.c+0−15
@@ -87,7 +87,6 @@ static ssize_t lcd_write(struct file *file, const char *buf, · 86 unmodified lines
8787 struct imon_context {
8888 struct device *dev;
8989 struct ir_dev_props *props;
90− struct ir_input_dev *ir;
9190 /* Newer devices have two interfaces */
9291 struct usb_device *usbdev_intf0;
9392 struct usb_device *usbdev_intf1;
@@ -1656,7 +1655,6 @@ static struct input_dev *imon_init_idev(struct imon_context *ictx) · 1562 unmodified lines
16561655 {
16571656 struct input_dev *idev;
16581657 struct ir_dev_props *props;
1659− struct ir_input_dev *ir;
16601658 int ret, i;
16611659
16621660 idev = input_allocate_device();
@@ -1671,12 +1669,6 @@ static struct input_dev *imon_init_idev(struct imon_context *ictx) · 8 unmodified lines
16711669 goto props_alloc_failed;
16721670 }
16731671
1674− ir = kzalloc(sizeof(struct ir_input_dev), GFP_KERNEL);
1675− if (!ir) {
1676− dev_err(ictx->dev, "remote ir input dev allocation failed\n");
1677− goto ir_dev_alloc_failed;
1678− }
1679−
16801672 snprintf(ictx->name_idev, sizeof(ictx->name_idev),
16811673 "iMON Remote (%04x:%04x)", ictx->vendor, ictx->product);
16821674 idev->name = ictx->name_idev;
@@ -1706,14 +1698,9 @@ static struct input_dev *imon_init_idev(struct imon_context *ictx) · 23 unmodified lines
17061698 props->change_protocol = imon_ir_change_protocol;
17071699 ictx->props = props;
17081700
1709− ictx->ir = ir;
1710− memcpy(&ir->dev, ictx->dev, sizeof(struct device));
1711−
17121701 usb_to_input_id(ictx->usbdev_intf0, &idev->id);
17131702 idev->dev.parent = ictx->dev;
17141703
1715− input_set_drvdata(idev, ir);
1716−
17171704 ret = ir_input_register(idev, RC_MAP_IMON_PAD, props, MOD_NAME);
17181705 if (ret < 0) {
17191706 dev_err(ictx->dev, "remote input dev register failed\n");
@@ -1723,8 +1710,6 @@ static struct input_dev *imon_init_idev(struct imon_context *ictx) · 3 unmodified lines
17231710 return idev;
17241711
17251712 idev_register_failed:
1726− kfree(ir);
1727−ir_dev_alloc_failed:
17281713 kfree(props);
17291714 props_alloc_failed:
17301715 input_free_device(idev);