Skip to content

Commit

Permalink
V4L/DVB: gspca - t613: Check the result of kmalloc
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-François Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Jean-François Moine authored and Mauro Carvalho Chehab committed May 18, 2010
1 parent 52897d8 commit 24f222e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions drivers/media/video/gspca/t613.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,10 @@ static void reg_w_buf(struct gspca_dev *gspca_dev,
u8 *tmpbuf;

tmpbuf = kmalloc(len, GFP_KERNEL);
if (!tmpbuf) {
err("Out of memory");
return;
}
memcpy(tmpbuf, buffer, len);
usb_control_msg(gspca_dev->dev,
usb_sndctrlpipe(gspca_dev->dev, 0),
Expand All @@ -542,10 +546,15 @@ static void reg_w_ixbuf(struct gspca_dev *gspca_dev,
int i;
u8 *p, *tmpbuf;

if (len * 2 <= USB_BUF_SZ)
if (len * 2 <= USB_BUF_SZ) {
p = tmpbuf = gspca_dev->usb_buf;
else
} else {
p = tmpbuf = kmalloc(len * 2, GFP_KERNEL);
if (!tmpbuf) {
err("Out of memory");
return;
}
}
i = len;
while (--i >= 0) {
*p++ = reg++;
Expand Down

0 comments on commit 24f222e

Please sign in to comment.