Skip to content

Commit 203537f

Browse files
Zhen Leigregkh
authored andcommitted
driver core: Fix error return code in really_probe()
[ 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>
1 parent 4225d35 commit 203537f

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

‎drivers/base/dd.c‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,8 @@ static int really_probe(struct device *dev, struct device_driver *drv)
543543
goto probe_failed;
544544
}
545545

546-
if (driver_sysfs_add(dev)) {
546+
ret = driver_sysfs_add(dev);
547+
if (ret) {
547548
pr_err("%s: driver_sysfs_add(%s) failed\n",
548549
__func__, dev_name(dev));
549550
goto probe_failed;
@@ -565,15 +566,18 @@ static int really_probe(struct device *dev, struct device_driver *drv)
565566
goto probe_failed;
566567
}
567568

568-
if (device_add_groups(dev, drv->dev_groups)) {
569+
ret = device_add_groups(dev, drv->dev_groups);
570+
if (ret) {
569571
dev_err(dev, "device_add_groups() failed\n");
570572
goto dev_groups_failed;
571573
}
572574

573-
if (dev_has_sync_state(dev) &&
574-
device_create_file(dev, &dev_attr_state_synced)) {
575-
dev_err(dev, "state_synced sysfs add failed\n");
576-
goto dev_sysfs_state_synced_failed;
575+
if (dev_has_sync_state(dev)) {
576+
ret = device_create_file(dev, &dev_attr_state_synced);
577+
if (ret) {
578+
dev_err(dev, "state_synced sysfs add failed\n");
579+
goto dev_sysfs_state_synced_failed;
580+
}
577581
}
578582

579583
if (test_remove) {

0 commit comments

Comments
 (0)