aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAmit Choudhary <amit2030@gmail.com>2006-12-20 09:30:45 -0300
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-12-27 14:19:51 -0200
commitd82d418a3af4d7d07151f9d45ca20f2ce61289a0 (patch)
tree87c4be0dd62e0bdcb153b514fe24f79511fe33df /drivers
parentcb2c7b4927c8f376b7ba9557978d8c59ed472664 (diff)
V4L/DVB (4990): Cpia2/cpia2_usb.c: fix error-path leak
Free previously allocated memory (in array elements) if kmalloc() returns NULL in submit_urbs(). Signed-off-by: Amit Choudhary <amit2030@gmail.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/cpia2/cpia2_usb.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/media/video/cpia2/cpia2_usb.c b/drivers/media/video/cpia2/cpia2_usb.c
index 28dc6a1a1e4..d8e929863a8 100644
--- a/drivers/media/video/cpia2/cpia2_usb.c
+++ b/drivers/media/video/cpia2/cpia2_usb.c
@@ -640,6 +640,10 @@ static int submit_urbs(struct camera_data *cam)
cam->sbuf[i].data =
kmalloc(FRAMES_PER_DESC * FRAME_SIZE_PER_DESC, GFP_KERNEL);
if (!cam->sbuf[i].data) {
+ while (--i >= 0) {
+ kfree(cam->sbuf[i].data);
+ cam->sbuf[i].data = NULL;
+ }
return -ENOMEM;
}
}