aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 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 }
387out: 389 return 0;
390
391out_deprecated:
392 sysfs_remove_link(&dev->kobj, "subsystem");
393out_subsys:
394 sysfs_remove_link(&bus->devices.kobj, dev->bus_id);
395out_id:
396 device_remove_attrs(bus, dev);
397out_put:
398 put_bus(dev->bus);
388 return error; 399 return error;
389} 400}
390 401