summaryrefslogtreecommitdiffstats
path: root/drivers/media/usb/usbvision
diff options
context:
space:
mode:
authorAlexey Khoroshilov <khoroshilov@ispras.ru>2013-06-10 22:32:29 +0200
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-06-21 16:29:24 +0200
commit090c65b694c362adb19ec9c27de216a808ee443c (patch)
tree2c37b858da95626a410a738f68c0926d40ef42cb /drivers/media/usb/usbvision
parent[media] media: i2c: tvp514x: add OF support (diff)
downloadlinux-090c65b694c362adb19ec9c27de216a808ee443c.tar.xz
linux-090c65b694c362adb19ec9c27de216a808ee443c.zip
[media] usbvision-video: fix memory leak of alt_max_pkt_size
1. usbvision->alt_max_pkt_size is not deallocated anywhere. 2. if allocation of usbvision->alt_max_pkt_size fails, there is no proper deallocation of already acquired resources. The patch adds kfree(usbvision->alt_max_pkt_size) to usbvision_release() as soon as other deallocations happen there. It calls usbvision_release() if allocation of usbvision->alt_max_pkt_size fails as soon as usbvision_release() is safe to work with incompletely initialized usbvision structure. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/usb/usbvision')
-rw-r--r--drivers/media/usb/usbvision/usbvision-video.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/media/usb/usbvision/usbvision-video.c b/drivers/media/usb/usbvision/usbvision-video.c
index f0a0b7f2da92..5c9e3123ad2e 100644
--- a/drivers/media/usb/usbvision/usbvision-video.c
+++ b/drivers/media/usb/usbvision/usbvision-video.c
@@ -1460,6 +1460,7 @@ static void usbvision_release(struct usb_usbvision *usbvision)
usbvision_remove_sysfs(usbvision->vdev);
usbvision_unregister_video(usbvision);
+ kfree(usbvision->alt_max_pkt_size);
usb_free_urb(usbvision->ctrl_urb);
@@ -1575,6 +1576,7 @@ static int usbvision_probe(struct usb_interface *intf,
usbvision->alt_max_pkt_size = kmalloc(32 * usbvision->num_alt, GFP_KERNEL);
if (usbvision->alt_max_pkt_size == NULL) {
dev_err(&intf->dev, "usbvision: out of memory!\n");
+ usbvision_release(usbvision);
return -ENOMEM;
}