Skip to contentSkip to conversation

dvb: return -ENOMEM if kzalloc failed in dvb_usb_device_init()

PATCH In review Roel Kluin 2 participants 4 messages Feb 2, 2010 – Feb 3, 2010 Media (V4L/DVB)

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 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.

---
Or shouldn't we?

drivers/media/dvb/dvb-usb/dvb-usb-init.c +1 -1
index e331db8..5d91f70 100644
@@ -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;
#1 lore raw

Am Dienstag, 2. Februar 2010 15:29:46 schrieb Roel Kluin:

Quoted 6 lines

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

---
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

author
#2 lore raw
Quoted 11 lines · Oliver Neukum

Am Dienstag, 2. Februar 2010 15:29:46 schrieb Roel Kluin:

Quoted 6 lines

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

---
Or shouldn't we?

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

Quoted 8 lines

       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

#3 lore raw

Am Mittwoch, 3. Februar 2010 17:02:49 schrieb roel kluin:

Quoted 9 lines
Quoted 9 lines

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;
       }
Quoted 4 lines
Quoted 1 line

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