summaryrefslogtreecommitdiffstats
path: root/drivers
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 13:13:48 +0200
commit1c6a694568dbbe9c6e6294c1b65ed88caf8df5bd (patch)
treea0820de8b9ecc69e397613f0c65da969c7962a90 /drivers
parentecc5486763604658933b7679db2e1c5432b28d3c (diff)
downloadlinux-stable-1c6a694568dbbe9c6e6294c1b65ed88caf8df5bd.tar.gz
linux-stable-1c6a694568dbbe9c6e6294c1b65ed88caf8df5bd.tar.bz2
linux-stable-1c6a694568dbbe9c6e6294c1b65ed88caf8df5bd.zip
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')
-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 17468f7d78ed..3ab80a7b4498 100644
--- a/drivers/media/usb/cpia2/cpia2_usb.c
+++ b/drivers/media/usb/cpia2/cpia2_usb.c
@@ -676,6 +676,10 @@ static int submit_urbs(struct camera_data *cam)
if (!urb) {
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;
}