summaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorCornelia Huck <cornelia.huck@de.ibm.com>2006-09-22 11:37:08 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2006-10-18 12:49:55 -0700
commit513e7337adc32cdfbffecb99953e45a44e812c2d (patch)
tree47179553f793f74366650b9b085f1350cc00a8e3 /drivers/base
parent1bb6881acae1c4f11a6e86f04df32ba45e95031d (diff)
downloadop-kernel-dev-513e7337adc32cdfbffecb99953e45a44e812c2d.zip
op-kernel-dev-513e7337adc32cdfbffecb99953e45a44e812c2d.tar.gz
driver core fixes: bus_add_device() cleanup on error
Correct cleanup in the error path of bus_add_device(). Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/bus.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index b90f6e6..d516f7d 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -372,19 +372,30 @@ int bus_add_device(struct device * dev)
pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id);
error = device_add_attrs(bus, dev);
if (error)
- goto out;
+ goto out_put;
error = sysfs_create_link(&bus->devices.kobj,
&dev->kobj, dev->bus_id);
if (error)
- goto out;
+ goto out_id;
error = sysfs_create_link(&dev->kobj,
&dev->bus->subsys.kset.kobj, "subsystem");
if (error)
- goto out;
+ goto out_subsys;
error = sysfs_create_link(&dev->kobj,
&dev->bus->subsys.kset.kobj, "bus");
+ if (error)
+ goto out_deprecated;
}
-out:
+ return 0;
+
+out_deprecated:
+ sysfs_remove_link(&dev->kobj, "subsystem");
+out_subsys:
+ sysfs_remove_link(&bus->devices.kobj, dev->bus_id);
+out_id:
+ device_remove_attrs(bus, dev);
+out_put:
+ put_bus(dev->bus);
return error;
}
OpenPOWER on IntegriCloud