Commit 4c0a56b2 authored by Junjie Mao's avatar Junjie Mao Committed by Greg Kroah-Hartman

driver core: bus: Goto appropriate labels on failure in bus_add_device

commit 1c34203a upstream.

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: fa6fdb33 ("driver core: bus_type: add dev_groups")
Signed-off-by: default avatarJunjie Mao <junjie_mao@yeah.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6361409a
...@@ -515,11 +515,11 @@ int bus_add_device(struct device *dev) ...@@ -515,11 +515,11 @@ int bus_add_device(struct device *dev)
goto out_put; goto out_put;
error = device_add_groups(dev, bus->dev_groups); error = device_add_groups(dev, bus->dev_groups);
if (error) if (error)
goto out_groups; goto out_id;
error = sysfs_create_link(&bus->p->devices_kset->kobj, error = sysfs_create_link(&bus->p->devices_kset->kobj,
&dev->kobj, dev_name(dev)); &dev->kobj, dev_name(dev));
if (error) if (error)
goto out_id; goto out_groups;
error = sysfs_create_link(&dev->kobj, error = sysfs_create_link(&dev->kobj,
&dev->bus->p->subsys.kobj, "subsystem"); &dev->bus->p->subsys.kobj, "subsystem");
if (error) if (error)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment