V4L/DVB (7460): bttv: Bt832 - fix possible NULL pointer deref
authorCyrill Gorcunov <gorcunov@gmail.com>
Tue, 1 Apr 2008 19:48:23 +0000 (16:48 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Sun, 6 Apr 2008 20:13:18 +0000 (17:13 -0300)
This patch does fix potential NULL pointer dereference

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/bt8xx/bt832.c

index a51876137880b26babbd24b6ae153aa6d2f9fad1..f92f06dec0d0a2fce3c09965e5e1b8570ca34acd 100644 (file)
@@ -97,6 +97,11 @@ int bt832_init(struct i2c_client *i2c_client_s)
        int rc;
 
        buf=kmalloc(65,GFP_KERNEL);
        int rc;
 
        buf=kmalloc(65,GFP_KERNEL);
+       if (!buf) {
+               v4l_err(&t->client,
+                       "Unable to allocate memory. Detaching.\n");
+               return 0;
+       }
        bt832_hexdump(i2c_client_s,buf);
 
        if(buf[0x40] != 0x31) {
        bt832_hexdump(i2c_client_s,buf);
 
        if(buf[0x40] != 0x31) {
@@ -211,7 +216,12 @@ bt832_command(struct i2c_client *client, unsigned int cmd, void *arg)
        switch (cmd) {
                case BT832_HEXDUMP: {
                        unsigned char *buf;
        switch (cmd) {
                case BT832_HEXDUMP: {
                        unsigned char *buf;
-                       buf=kmalloc(65,GFP_KERNEL);
+                       buf = kmalloc(65, GFP_KERNEL);
+                       if (!buf) {
+                               v4l_err(&t->client,
+                                       "Unable to allocate memory\n");
+                               break;
+                       }
                        bt832_hexdump(&t->client,buf);
                        kfree(buf);
                }
                        bt832_hexdump(&t->client,buf);
                        kfree(buf);
                }