* [patch] [media] cx18: check for allocation failure in cx18_read_eeprom()
@ 2013-11-22 7:51 Dan Carpenter
2013-11-22 9:13 ` Dan Carpenter
2013-11-22 11:32 ` Andy Walls
0 siblings, 2 replies; 5+ messages in thread
From: Dan Carpenter @ 2013-11-22 7:51 UTC (permalink / raw)
To: Andy Walls
Cc: Mauro Carvalho Chehab, ivtv-devel, linux-media, kernel-janitors
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>
diff --git a/drivers/media/pci/cx18/cx18-driver.c b/drivers/media/pci/cx18/cx18-driver.c
index c1f8cc6f14b2..716bdc57fac6 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;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [patch] [media] cx18: check for allocation failure in cx18_read_eeprom()
2013-11-22 7:51 [patch] [media] cx18: check for allocation failure in cx18_read_eeprom() Dan Carpenter
@ 2013-11-22 9:13 ` Dan Carpenter
2013-11-22 9:21 ` Hans Verkuil
2013-11-22 11:32 ` Andy Walls
1 sibling, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2013-11-22 9:13 UTC (permalink / raw)
To: Andy Walls; +Cc: Mauro Carvalho Chehab, linux-media, kernel-janitors
Btw, the MAINTAINERS file says the ivtv list is moderated but actually
it's a subscriber only list... Sucks.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] [media] cx18: check for allocation failure in cx18_read_eeprom()
2013-11-22 9:13 ` Dan Carpenter
@ 2013-11-22 9:21 ` Hans Verkuil
2013-11-22 11:34 ` Andy Walls
0 siblings, 1 reply; 5+ messages in thread
From: Hans Verkuil @ 2013-11-22 9:21 UTC (permalink / raw)
To: Dan Carpenter
Cc: Andy Walls, Mauro Carvalho Chehab, linux-media, kernel-janitors
Andy,
Should we perhaps change the MAINTAINERS file to point to the linux-media list
instead?
Regards,
Hans
On 11/22/2013 10:13 AM, Dan Carpenter wrote:
> Btw, the MAINTAINERS file says the ivtv list is moderated but actually
> it's a subscriber only list... Sucks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] [media] cx18: check for allocation failure in cx18_read_eeprom()
2013-11-22 7:51 [patch] [media] cx18: check for allocation failure in cx18_read_eeprom() Dan Carpenter
2013-11-22 9:13 ` Dan Carpenter
@ 2013-11-22 11:32 ` Andy Walls
1 sibling, 0 replies; 5+ messages in thread
From: Andy Walls @ 2013-11-22 11:32 UTC (permalink / raw)
To: Dan Carpenter
Cc: Mauro Carvalho Chehab, ivtv-devel, linux-media, kernel-janitors
On Fri, 2013-11-22 at 10:51 +0300, Dan Carpenter wrote:
> 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>
> diff --git a/drivers/media/pci/cx18/cx18-driver.c b/drivers/media/pci/cx18/cx18-driver.c
> index c1f8cc6f14b2..716bdc57fac6 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;
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] [media] cx18: check for allocation failure in cx18_read_eeprom()
2013-11-22 9:21 ` Hans Verkuil
@ 2013-11-22 11:34 ` Andy Walls
0 siblings, 0 replies; 5+ messages in thread
From: Andy Walls @ 2013-11-22 11:34 UTC (permalink / raw)
To: Hans Verkuil
Cc: Dan Carpenter, Mauro Carvalho Chehab, linux-media,
kernel-janitors
On Fri, 2013-11-22 at 10:21 +0100, Hans Verkuil wrote:
> 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
> Regards,
>
> Hans
>
> On 11/22/2013 10:13 AM, Dan Carpenter wrote:
> > 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 majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-11-22 11:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-22 7:51 [patch] [media] cx18: check for allocation failure in cx18_read_eeprom() Dan Carpenter
2013-11-22 9:13 ` Dan Carpenter
2013-11-22 9:21 ` Hans Verkuil
2013-11-22 11:34 ` Andy Walls
2013-11-22 11:32 ` Andy Walls
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox