aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/uvc/uvc_status.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@skynet.be>2009-01-22 10:45:10 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:42:26 -0400
commitf180152376c984a6faa9decb8f2811c373da9141 (patch)
tree61efd7457f949e1bfa78f931e748659ec2d315ac /drivers/media/video/uvc/uvc_status.c
parentefdc8a9585ce02e70e538e46f235aefd63a3f8da (diff)
V4L/DVB (10296): uvcvideo: Fix memory leak in input device handling
The dynamically allocated input_dev->phys buffer isn't freed when unregistering the device. As the input layer doesn't provide any release callback, use a fixed-size buffer inside the uvc_device structure. Signed-off-by: Laurent Pinchart <laurent.pinchart@skynet.be> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/uvc/uvc_status.c')
-rw-r--r--drivers/media/video/uvc/uvc_status.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/media/video/uvc/uvc_status.c b/drivers/media/video/uvc/uvc_status.c
index c705f248da88..21d87124986b 100644
--- a/drivers/media/video/uvc/uvc_status.c
+++ b/drivers/media/video/uvc/uvc_status.c
@@ -24,26 +24,19 @@
24#ifdef CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV 24#ifdef CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV
25static int uvc_input_init(struct uvc_device *dev) 25static int uvc_input_init(struct uvc_device *dev)
26{ 26{
27 struct usb_device *udev = dev->udev;
28 struct input_dev *input; 27 struct input_dev *input;
29 char *phys = NULL;
30 int ret; 28 int ret;
31 29
32 input = input_allocate_device(); 30 input = input_allocate_device();
33 if (input == NULL) 31 if (input == NULL)
34 return -ENOMEM; 32 return -ENOMEM;
35 33
36 phys = kmalloc(6 + strlen(udev->bus->bus_name) + strlen(udev->devpath), 34 usb_make_path(dev->udev, dev->input_phys, sizeof(dev->input_phys));
37 GFP_KERNEL); 35 strlcat(dev->input_phys, "/button", sizeof(dev->input_phys));
38 if (phys == NULL) {
39 ret = -ENOMEM;
40 goto error;
41 }
42 sprintf(phys, "usb-%s-%s", udev->bus->bus_name, udev->devpath);
43 36
44 input->name = dev->name; 37 input->name = dev->name;
45 input->phys = phys; 38 input->phys = dev->input_phys;
46 usb_to_input_id(udev, &input->id); 39 usb_to_input_id(dev->udev, &input->id);
47 input->dev.parent = &dev->intf->dev; 40 input->dev.parent = &dev->intf->dev;
48 41
49 __set_bit(EV_KEY, input->evbit); 42 __set_bit(EV_KEY, input->evbit);
@@ -57,7 +50,6 @@ static int uvc_input_init(struct uvc_device *dev)
57 50
58error: 51error:
59 input_free_device(input); 52 input_free_device(input);
60 kfree(phys);
61 return ret; 53 return ret;
62} 54}
63 55