diff options
author | Cornelia Huck <cornelia.huck@de.ibm.com> | 2006-09-22 05:37:08 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-10-18 15:49:55 -0400 |
commit | 513e7337adc32cdfbffecb99953e45a44e812c2d (patch) | |
tree | 47179553f793f74366650b9b085f1350cc00a8e3 /drivers/base/bus.c | |
parent | 1bb6881acae1c4f11a6e86f04df32ba45e95031d (diff) |
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/bus.c')
-rw-r--r-- | drivers/base/bus.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index b90f6e6f6442..d516f7d5f168 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -372,19 +372,30 @@ int bus_add_device(struct device * dev) | |||
372 | pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id); | 372 | pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id); |
373 | error = device_add_attrs(bus, dev); | 373 | error = device_add_attrs(bus, dev); |
374 | if (error) | 374 | if (error) |
375 | goto out; | 375 | goto out_put; |
376 | error = sysfs_create_link(&bus->devices.kobj, | 376 | error = sysfs_create_link(&bus->devices.kobj, |
377 | &dev->kobj, dev->bus_id); | 377 | &dev->kobj, dev->bus_id); |
378 | if (error) | 378 | if (error) |
379 | goto out; | 379 | goto out_id; |
380 | error = sysfs_create_link(&dev->kobj, | 380 | error = sysfs_create_link(&dev->kobj, |
381 | &dev->bus->subsys.kset.kobj, "subsystem"); | 381 | &dev->bus->subsys.kset.kobj, "subsystem"); |
382 | if (error) | 382 | if (error) |
383 | goto out; | 383 | goto out_subsys; |
384 | error = sysfs_create_link(&dev->kobj, | 384 | error = sysfs_create_link(&dev->kobj, |
385 | &dev->bus->subsys.kset.kobj, "bus"); | 385 | &dev->bus->subsys.kset.kobj, "bus"); |
386 | if (error) | ||
387 | goto out_deprecated; | ||
386 | } | 388 | } |
387 | out: | 389 | return 0; |
390 | |||
391 | out_deprecated: | ||
392 | sysfs_remove_link(&dev->kobj, "subsystem"); | ||
393 | out_subsys: | ||
394 | sysfs_remove_link(&bus->devices.kobj, dev->bus_id); | ||
395 | out_id: | ||
396 | device_remove_attrs(bus, dev); | ||
397 | out_put: | ||
398 | put_bus(dev->bus); | ||
388 | return error; | 399 | return error; |
389 | } | 400 | } |
390 | 401 | ||