From 529d4a90d815016b14241e3473fe222df8739d32 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 20 Dec 2006 10:30:45 -0200 Subject: Cpia2/cpia2_usb.c: fix error-path leak From: Amit Choudhary 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 --- linux/drivers/media/video/cpia2/cpia2_usb.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'linux/drivers/media/video/cpia2') diff --git a/linux/drivers/media/video/cpia2/cpia2_usb.c b/linux/drivers/media/video/cpia2/cpia2_usb.c index 0d4bb91dc..87442ede0 100644 --- a/linux/drivers/media/video/cpia2/cpia2_usb.c +++ b/linux/drivers/media/video/cpia2/cpia2_usb.c @@ -648,6 +648,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; } } -- cgit v1.2.3