summaryrefslogtreecommitdiff
path: root/drivers/media/usb/cpia2
diff options
context:
space:
mode:
authorWenwen Wang <wenwen@cs.uga.edu>2019-08-17 02:27:46 -0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-10-05 12:27:48 +0200
commita9df2fd8e064ea6426297adf2ac78b5e4a6d2b4b (patch)
tree5c2f489f7f82aa6b4ab28c6b69e73dc516e9f565 /drivers/media/usb/cpia2
parent70e2968f3bf2bce0abf2a2e9a9516652d035a376 (diff)
media: cpia2_usb: fix memory leaks
[ Upstream commit 1c770f0f52dca1a2323c594f01f5ec6f1dddc97f ] In submit_urbs(), 'cam->sbuf[i].data' is allocated through kmalloc_array(). However, it is not deallocated if the following allocation for urbs fails. To fix this issue, free 'cam->sbuf[i].data' if usb_alloc_urb() fails. Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/media/usb/cpia2')
-rw-r--r--drivers/media/usb/cpia2/cpia2_usb.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/media/usb/cpia2/cpia2_usb.c b/drivers/media/usb/cpia2/cpia2_usb.c
index 41ea00ac3a87..76b9cb940b87 100644
--- a/drivers/media/usb/cpia2/cpia2_usb.c
+++ b/drivers/media/usb/cpia2/cpia2_usb.c
@@ -665,6 +665,10 @@ static int submit_urbs(struct camera_data *cam)
ERR("%s: usb_alloc_urb error!\n", __func__);
for (j = 0; j < i; j++)
usb_free_urb(cam->sbuf[j].urb);
+ for (j = 0; j < NUM_SBUF; j++) {
+ kfree(cam->sbuf[j].data);
+ cam->sbuf[j].data = NULL;
+ }
return -ENOMEM;
}