Skip to contentSkip to conversation

cx18: check for allocation failure in cx18_read_eeprom()

PATCH In review Dan Carpenter 3 participants 5 messages Nov 22, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cx18: check for allocation failure in cx18_read_eeprom()

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')
drivers/media/pci/cx18/cx18-driver.c +4 -1
index c1f8cc6f14b2..716bdc57fac6 100644
@@ -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;
 
#1 lore raw

Btw, the MAINTAINERS file says the ivtv list is moderated but actually it's a subscriber only list... Sucks.

regards,
dan carpenter

#2 lore raw

Andy,

Should we perhaps change the MAINTAINERS file to point to the linux-media list instead?

Regards,

Hans

Quoted 2 lines · Dan Carpenter

Btw, the MAINTAINERS file says the ivtv list is moderated but actually it's a subscriber only list... Sucks.

maintainer
#3 lore raw
Quoted 4 lines · Hans Verkuil

Andy,

Should we perhaps change the MAINTAINERS file to point to the linux-media list instead?

Yes. When I get time this weekend, I can submit a patch; unless you beat me to it.

Regards,
Andy

Quoted 12 lines

Regards,

Hans

Quoted 2 lines · Dan Carpenter

Btw, the MAINTAINERS file says the ivtv list is moderated but actually it's a subscriber only list... Sucks.

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer Acked-by on v1 1/1
#4 lore raw
In reply to Dan Carpenter
Quoted 6 lines · Dan Carpenter

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')
Quoted 26 lines
drivers/media/pci/cx18/cx18-driver.c +4 -2
index c1f8cc6f14b2..716bdc57fac6 100644
@@ -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;
 
--

To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html