提交 1c770f0f 编写于 作者: W Wenwen Wang 提交者: Mauro Carvalho Chehab

media: cpia2_usb: fix memory leaks

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: NWenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: NHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: NMauro Carvalho Chehab <mchehab+samsung@kernel.org>
上级 a8ef0488
...@@ -676,6 +676,10 @@ static int submit_urbs(struct camera_data *cam) ...@@ -676,6 +676,10 @@ static int submit_urbs(struct camera_data *cam)
if (!urb) { if (!urb) {
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
usb_free_urb(cam->sbuf[j].urb); 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; return -ENOMEM;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册