public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* dereferencing uninitialized variable in anysee_probe()
@ 2010-05-31 15:09 Dan Carpenter
  2010-05-31 15:22 ` Antti Palosaari
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2010-05-31 15:09 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media

Hi I'm going through some smatch stuff and I had a question.

drivers/media/dvb/dvb-usb/anysee.c +482 anysee_probe(30)
	warn: variable dereferenced before check 'd'

   466          ret = dvb_usb_device_init(intf, &anysee_properties, THIS_MODULE, &d,
   467                  adapter_nr);

	If we're in a cold state then dvb_usb_device_init() can return
	zero but d is uninitialized here.

   468          if (ret)
   469                  return ret;
   470
   471          alt = usb_altnum_to_altsetting(intf, 0);
   472          if (alt == NULL) {
   473                  deb_info("%s: no alt found!\n", __func__);
   474                  return -ENODEV;
   475          }
   476
   477          ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber,
                                        ^^^^^^^
	That would lead to an oops here.

   478                  alt->desc.bAlternateSetting);

I'm not sure how to fix this.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: dereferencing uninitialized variable in anysee_probe()
  2010-05-31 15:09 dereferencing uninitialized variable in anysee_probe() Dan Carpenter
@ 2010-05-31 15:22 ` Antti Palosaari
  2010-05-31 19:13   ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Antti Palosaari @ 2010-05-31 15:22 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-media

Terve Dan,

On 05/31/2010 06:09 PM, Dan Carpenter wrote:
> Hi I'm going through some smatch stuff and I had a question.
>
> drivers/media/dvb/dvb-usb/anysee.c +482 anysee_probe(30)
> 	warn: variable dereferenced before check 'd'
>
>     466          ret = dvb_usb_device_init(intf,&anysee_properties, THIS_MODULE,&d,
>     467                  adapter_nr);
>
> 	If we're in a cold state then dvb_usb_device_init() can return
> 	zero but d is uninitialized here.

Anysee is always warm. Its USB-bridge, Cypress FX2, uploads firmware 
from eeprom and due to that it is never cold from the drivers point of view.

*cold means device needs firmware upload from driver
*warm means device is ready. Firmware is already uploaded or it is not 
needed at all.

>     468          if (ret)
>     469                  return ret;
>     470
>     471          alt = usb_altnum_to_altsetting(intf, 0);
>     472          if (alt == NULL) {
>     473                  deb_info("%s: no alt found!\n", __func__);
>     474                  return -ENODEV;
>     475          }
>     476
>     477          ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber,
>                                          ^^^^^^^
> 	That would lead to an oops here.
>
>     478                  alt->desc.bAlternateSetting);
>
> I'm not sure how to fix this.

After that answer, do you still see problem?

best regards
Antti
-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: dereferencing uninitialized variable in anysee_probe()
  2010-05-31 15:22 ` Antti Palosaari
@ 2010-05-31 19:13   ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2010-05-31 19:13 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media

On Mon, May 31, 2010 at 06:22:49PM +0300, Antti Palosaari wrote:
> Terve Dan,
>
> On 05/31/2010 06:09 PM, Dan Carpenter wrote:
>> Hi I'm going through some smatch stuff and I had a question.
>>
>> drivers/media/dvb/dvb-usb/anysee.c +482 anysee_probe(30)
>> 	warn: variable dereferenced before check 'd'
>>
>>     466          ret = dvb_usb_device_init(intf,&anysee_properties, THIS_MODULE,&d,
>>     467                  adapter_nr);
>>
>> 	If we're in a cold state then dvb_usb_device_init() can return
>> 	zero but d is uninitialized here.
>
> Anysee is always warm. Its USB-bridge, Cypress FX2, uploads firmware  
> from eeprom and due to that it is never cold from the drivers point of 
> view.
>
> *cold means device needs firmware upload from driver
> *warm means device is ready. Firmware is already uploaded or it is not  
> needed at all.
>

Wow.  Thanks for the quick response.  I was just auditing the code and
noticed some extra null checking which made me confused.  I'll send a
patch for that.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-05-31 19:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-31 15:09 dereferencing uninitialized variable in anysee_probe() Dan Carpenter
2010-05-31 15:22 ` Antti Palosaari
2010-05-31 19:13   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox