V4L/DVB: gspca - t613: Check the result of kmalloc
authorJean-François Moine <moinejf@free.fr>
Sun, 7 Mar 2010 08:58:55 +0000 (05:58 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 18 May 2010 03:46:28 +0000 (00:46 -0300)
Signed-off-by: Jean-François Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/gspca/t613.c

index 668a7536af90707686b3c12f761af86657b41507..8c7dadef8211f5c72c18e8aa953801fe8a276431 100644 (file)
@@ -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),
@@ -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++;