diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2013-11-22 04:51:47 -0300 |
---|---|---|
committer | Jiri Slaby <jslaby@suse.cz> | 2014-03-31 14:22:26 +0200 |
commit | d5ce3633797811aa7274d49cc13aff4d1665b22e (patch) | |
tree | 2358fdb96d1177b4326b4ce2e31644078d10a516 | |
parent | 560febde5250115f1ac28fe21ee72790e09e42d9 (diff) |
media: cx18: check for allocation failure in cx18_read_eeprom()
commit e351bf25fa373a3de0be2141b962c5c3c27006a2 upstream.
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>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
-rw-r--r-- | drivers/media/pci/cx18/cx18-driver.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/media/pci/cx18/cx18-driver.c b/drivers/media/pci/cx18/cx18-driver.c index 6386ced910c2..91c694ba42f4 100644 --- a/drivers/media/pci/cx18/cx18-driver.c +++ b/drivers/media/pci/cx18/cx18-driver.c @@ -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; |