Skip to contentSkip to conversation

driver core: Fix error return code in really_probe()

PATCH New Zhen Lei 1 participant 1 message Jul 7, 2021 Driver core

lore
Share & tools
lore

Zhen Lei

author
#0 lore raw

PATCH 1/1 driver core: Fix error return code in really_probe()

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

Fixes 1901fb2604fb ("Driver core: fix "driver" symlink timing")
Fixes 23b6904442d0 ("driver core: add dev_groups to all drivers")
Fixes 8fd456ec0cf0 ("driver core: Add state_synced sysfs file for devices that support it")
---
 drivers/base/dd.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/base/dd.c +10 -6
index daeb9b5763ae..2b8cdb78384c 100644
@@ -580,7 +580,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;
@@ -602,15 +603,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) {
Signature · 1 line
2.25.1