[media] cx18: check for allocation failure in cx18_read_eeprom()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 22 Nov 2013 07:51:47 +0000 (04:51 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Tue, 10 Dec 2013 17:36:11 +0000 (15:36 -0200)
It upsets static checkers when we don't check for allocation failure.  I
moved the memset() of "tv" earlier so we don't use uninitialized data on
error.
Fixes: 1d212cf0c2d8 ('[media] cx18: struct i2c_client is too big for stack')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Andy Walls <awalls@md.metrocast.net>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/pci/cx18/cx18-driver.c

index c1f8cc6f14b21ed74b024dd8c0b4425ed1425cdc..716bdc57fac6fb298a904602675605d21c486d2a 100644 (file)
@@ -327,13 +327,16 @@ void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv)
        struct i2c_client *c;
        u8 eedata[256];
 
+       memset(tv, 0, sizeof(*tv));
+
        c = kzalloc(sizeof(*c), GFP_KERNEL);
+       if (!c)
+               return;
 
        strlcpy(c->name, "cx18 tveeprom tmp", sizeof(c->name));
        c->adapter = &cx->i2c_adap[0];
        c->addr = 0xa0 >> 1;
 
-       memset(tv, 0, sizeof(*tv));
        if (tveeprom_read(c, eedata, sizeof(eedata)))
                goto ret;