From: Amit Choudhary Date: Wed, 20 Dec 2006 12:30:45 +0000 (-0300) Subject: V4L/DVB (4990): Cpia2/cpia2_usb.c: fix error-path leak X-Git-Tag: v2.6.20-rc3~55^2~10 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d82d418a3af4d7d07151f9d45ca20f2ce61289a0;p=linux-2.6 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 Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/video/cpia2/cpia2_usb.c b/drivers/media/video/cpia2/cpia2_usb.c index 28dc6a1a1e..d8e929863a 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; } }