This is a note to let you know that I've just added the patch titled
Subject: bus_add_device() losing an error return from the probe() method
to my gregkh-2.6 tree. Its filename is
bus_add_device-losing-an-error-return-from-the-probe-method.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
Patches currently in gregkh-2.6 which might be from [email protected] are
driver/bus_add_device-losing-an-error-return-from-the-probe-method.patch
>From [email protected] Thu Mar 23 21:32:00 2006
Message-ID: <[email protected]>
Date: Fri, 24 Mar 2006 06:32:57 +0100
From: Rene Herman <[email protected]>
To: Greg Kroah-Hartman <[email protected]>
Cc: Takashi Iwai <[email protected]>, ALSA devel <[email protected]>, Linux Kernel <[email protected]>
Subject: bus_add_device() losing an error return from the probe() method
ALSA moved all ISA drivers over to the platform_driver interface in
2.6.16, using this code structure in the module_inits:
cards = 0;
for (i = 0; i < SNDRV_CARDS; i++) {
struct platform_device *device;
device = platform_device_register_simple(
SND_FOO_DRIVER, i, NULL, 0);
if (IS_ERR(device)) {
err = PTR_ERR(device);
goto errout;
}
devices[i] = device;
cards++;
}
if (!cards) {
printk(KERN_ERR "FOO soundcard not found or device busy\n");
err = -ENODEV;
goto errout;
}
return 0;
errout:
snd_foo_unregister_all();
return err;
Unfortunately, the snd_foo_unregister_all() part here is unreachable
under normal circumstances, since platform_device_register_simple()
returns !IS_ERR, regardless of what the driver probe method returned.
The driver then never fails to load, even when no cards were found.
An error return from the driver probe() method is carried up through
device_attach, but is then dropped on the floor in bus_add_device(). If
I apply the attached patch, things work as I (and ALSA it seems) expect.
From: Rene Herman <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
drivers/base/bus.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
--- gregkh-2.6.orig/drivers/base/bus.c
+++ gregkh-2.6/drivers/base/bus.c
@@ -372,14 +372,17 @@ int bus_add_device(struct device * dev)
if (bus) {
pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id);
- device_attach(dev);
+ error = device_attach(dev);
+ if (error < 0)
+ goto exit;
klist_add_tail(&dev->knode_bus, &bus->klist_devices);
error = device_add_attrs(bus, dev);
- if (!error) {
- sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id);
- sysfs_create_link(&dev->kobj, &dev->bus->subsys.kset.kobj, "bus");
- }
+ if (error)
+ goto exit;
+ sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id);
+ sysfs_create_link(&dev->kobj, &dev->bus->subsys.kset.kobj, "bus");
}
+exit:
return error;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]