Skip to content

Commit

Permalink
V4L/DVB (4990): Cpia2/cpia2_usb.c: fix error-path leak
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Amit Choudhary authored and Mauro Carvalho Chehab committed Dec 27, 2006
1 parent cb2c7b4 commit d82d418
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/media/video/cpia2/cpia2_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit d82d418

Please sign in to comment.