2010-02-02 14:23:38

by Roel Kluin

[permalink] [raw]
Subject: [PATCH] dvb: return -ENOMEM if kzalloc failed in dvb_usb_device_init()

If in a cold state and the download succeeded ret is zero, but we
should return -ENOMEM.

Signed-off-by: Roel Kluin <[email protected]>
---
Or shouldn't we?

diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
index e331db8..5d91f70 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
@@ -243,7 +243,7 @@ int dvb_usb_device_init(struct usb_interface *intf,
d = kzalloc(sizeof(struct dvb_usb_device),GFP_KERNEL);
if (d == NULL) {
err("no memory for 'struct dvb_usb_device'");
- return ret;
+ return -ENOMEM;
}

d->udev = udev;


2010-02-02 14:29:38

by Oliver Neukum

[permalink] [raw]
Subject: Re: [PATCH] dvb: return -ENOMEM if kzalloc failed in dvb_usb_device_init()

Am Dienstag, 2. Februar 2010 15:29:46 schrieb Roel Kluin:
> If in a cold state and the download succeeded ret is zero, but we
> should return -ENOMEM.
>
> Signed-off-by: Roel Kluin <[email protected]>
> ---
> Or shouldn't we?

We should and we do if cold==0.
The bug is caused by this:

if (cold) {
info("found a '%s' in cold state, will try to load a firmware",desc->name);
ret = dvb_usb_download_firmware(udev,props);
if (!props->no_reconnect || ret != 0)
return ret;
}

which overwrites ret

Regards
Oliver

2010-02-03 16:03:13

by Roel Kluin

[permalink] [raw]
Subject: Re: [PATCH] dvb: return -ENOMEM if kzalloc failed in dvb_usb_device_init()

On Tue, Feb 2, 2010 at 3:29 PM, Oliver Neukum <[email protected]> wrote:
> Am Dienstag, 2. Februar 2010 15:29:46 schrieb Roel Kluin:
>> If in a cold state and the download succeeded ret is zero, but we
>> should return -ENOMEM.
>>
>> Signed-off-by: Roel Kluin <[email protected]>
>> ---
>> Or shouldn't we?
>
> We should and we do if cold==0.
> The bug is caused by this:
>
>        if (cold) {
>                info("found a '%s' in cold state, will try to load a firmware",desc->name);
>                ret = dvb_usb_download_firmware(udev,props);
>                if (!props->no_reconnect || ret != 0)
>                        return ret;
>        }
>
> which overwrites ret

Is that an ack or do you want me to add an int (e.g. rc) that
handles the dvb_usb_download_firmware() return value?

Roel

2010-02-03 16:16:13

by Oliver Neukum

[permalink] [raw]
Subject: Re: [PATCH] dvb: return -ENOMEM if kzalloc failed in dvb_usb_device_init()

Am Mittwoch, 3. Februar 2010 17:02:49 schrieb roel kluin:
> > The bug is caused by this:
> >
> > if (cold) {
> > info("found a '%s' in cold state, will try to load a firmware",desc->name);
> > ret = dvb_usb_download_firmware(udev,props);
> > if (!props->no_reconnect || ret != 0)
> > return ret;
> > }
> >
> > which overwrites ret
>
> Is that an ack or do you want me to add an int (e.g. rc) that
> handles the dvb_usb_download_firmware() return value?

This is an ack with an additional comment that this function is in need of
a cleanup due to unnecessary subtlety.

Regards
Oliver