Skip to content

Commit

Permalink
driver core: Fix error return code in really_probe()
Browse files Browse the repository at this point in the history
[ Upstream commit f04948d ]

In the case of error handling, the error code returned by the subfunction
should be propagated instead of 0.

Fixes: 1901fb2 ("Driver core: fix "driver" symlink timing")
Fixes: 23b6904 ("driver core: add dev_groups to all drivers")
Fixes: 8fd456e ("driver core: Add state_synced sysfs file for devices that support it")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Link: https://lore.kernel.org/r/20210707074301.2722-1-thunder.leizhen@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Zhen Lei authored and gregkh committed Sep 15, 2021
1 parent 8279791 commit 5a6a3c8
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions drivers/base/dd.c
Expand Up @@ -560,7 +560,8 @@ static int really_probe(struct device *dev, struct device_driver *drv)
goto probe_failed;
}

if (driver_sysfs_add(dev)) {
ret = driver_sysfs_add(dev);
if (ret) {
pr_err("%s: driver_sysfs_add(%s) failed\n",
__func__, dev_name(dev));
goto probe_failed;
Expand All @@ -582,15 +583,18 @@ static int really_probe(struct device *dev, struct device_driver *drv)
goto probe_failed;
}

if (device_add_groups(dev, drv->dev_groups)) {
ret = device_add_groups(dev, drv->dev_groups);
if (ret) {
dev_err(dev, "device_add_groups() failed\n");
goto dev_groups_failed;
}

if (dev_has_sync_state(dev) &&
device_create_file(dev, &dev_attr_state_synced)) {
dev_err(dev, "state_synced sysfs add failed\n");
goto dev_sysfs_state_synced_failed;
if (dev_has_sync_state(dev)) {
ret = device_create_file(dev, &dev_attr_state_synced);
if (ret) {
dev_err(dev, "state_synced sysfs add failed\n");
goto dev_sysfs_state_synced_failed;
}
}

if (test_remove) {
Expand Down

0 comments on commit 5a6a3c8

Please sign in to comment.