summaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cpia2
diff options
context:
space:
mode:
authorAmit Choudhary <amit2030@gmail.com>2006-12-20 13:30:45 +0100
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-12-27 17:19:51 +0100
commitd82d418a3af4d7d07151f9d45ca20f2ce61289a0 (patch)
tree87c4be0dd62e0bdcb153b514fe24f79511fe33df /drivers/media/video/cpia2
parentV4L/DVB (4988): Cx2341x audio_properties is an u16, not u8 (diff)
downloadlinux-d82d418a3af4d7d07151f9d45ca20f2ce61289a0.tar.xz
linux-d82d418a3af4d7d07151f9d45ca20f2ce61289a0.zip
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/media/video/cpia2')
-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 28dc6a1a1e43..d8e929863a88 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;
}
}