Skip to content

Commit

Permalink
driver core: bus: Goto appropriate labels on failure in bus_add_device
Browse files Browse the repository at this point in the history
It is not necessary to call device_remove_groups() when device_add_groups()
fails.

The group added by device_add_groups() should be removed if sysfs_create_link()
fails.

Fixes: fa6fdb3 ("driver core: bus_type: add dev_groups")
Signed-off-by: Junjie Mao <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Junjie Mao authored and gregkh committed Mar 25, 2015
1 parent bb2b407 commit 1c34203
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/base/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,11 @@ int bus_add_device(struct device *dev)
goto out_put;
error = device_add_groups(dev, bus->dev_groups);
if (error)
goto out_groups;
goto out_id;
error = sysfs_create_link(&bus->p->devices_kset->kobj,
&dev->kobj, dev_name(dev));
if (error)
goto out_id;
goto out_groups;
error = sysfs_create_link(&dev->kobj,
&dev->bus->p->subsys.kobj, "subsystem");
if (error)
Expand Down

0 comments on commit 1c34203

Please sign in to comment.