Skip to contentSkip to conversation

driver core: auxiliary bus: Fix IS_ERR() vs NULL mixup in __devm_auxiliary_device_create()

PATCH In review Dan Carpenter 3 participants 3 messages Apr 23, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 driver core: auxiliary bus: Fix IS_ERR() vs NULL mixup in __devm_auxiliary_device_create()

This code was originally going to use error pointers but we decided it should return NULL instead. The error pointer code in __devm_auxiliary_device_create() was left over from the first version. Update it to use NULL. No callers have been merged yet, so that makes this change simple and self contained.

Fixes eaa0d30216c1 ("driver core: auxiliary bus: add device creation helpers")

---
v2: Originally I just updated the check for auxiliary_device_create()
failure and returned ERR_PTR(-ENOMEM) but obviously the auxiliary_device_create() and devm_auxiliary_device_create() functions should return the same thing, NULL.

 drivers/base/auxiliary.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/base/auxiliary.c +3 -3
index 810b6105a75d..dba7c8e13a53 100644
@@ -491,13 +491,13 @@ struct auxiliary_device *__devm_auxiliary_device_create(struct device *dev,
 	int ret;
 
 	auxdev = auxiliary_device_create(dev, modname, devname, platform_data, id);
-	if (IS_ERR(auxdev))
-		return auxdev;
+	if (!auxdev)
+		return NULL;
 
 	ret = devm_add_action_or_reset(dev, auxiliary_device_destroy,
 				       auxdev);
 	if (ret)
-		return ERR_PTR(ret);
+		return NULL;
 
 	return auxdev;
 }
Signature · 1 line
2.47.2
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Dan Carpenter

This code was originally going to use error pointers but we decided it should return NULL instead. The error pointer code in __devm_auxiliary_device_create() was left over from the first version. Update it to use NULL. No callers have been merged yet, so that makes this change simple and self contained.

Fixes eaa0d30216c1 ("driver core: auxiliary bus: add device creation helpers")

Thanks !

Quoted 30 lines

---
v2: Originally I just updated the check for auxiliary_device_create()
failure and returned ERR_PTR(-ENOMEM) but obviously the auxiliary_device_create() and devm_auxiliary_device_create() functions should return the same thing, NULL.

 drivers/base/auxiliary.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/base/auxiliary.c +3 -3
index 810b6105a75d..dba7c8e13a53 100644
@@ -491,13 +491,13 @@ struct auxiliary_device *__devm_auxiliary_device_create(struct device *dev,
 	int ret;
 
 	auxdev = auxiliary_device_create(dev, modname, devname, platform_data, id);
-	if (IS_ERR(auxdev))
-		return auxdev;
+	if (!auxdev)
+		return NULL;
 
 	ret = devm_add_action_or_reset(dev, auxiliary_device_destroy,
 				       auxdev);
 	if (ret)
-		return ERR_PTR(ret);
+		return NULL;
 
 	return auxdev;
 }
Signature · 1 line
Jerome
reviewer Reviewed-by on v2 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 8 lines · Dan Carpenter

This code was originally going to use error pointers but we decided it should return NULL instead. The error pointer code in __devm_auxiliary_device_create() was left over from the first version. Update it to use NULL. No callers have been merged yet, so that makes this change simple and self contained.

Fixes eaa0d30216c1 ("driver core: auxiliary bus: add device creation helpers")
Quoted 9 lines

---
v2: Originally I just updated the check for auxiliary_device_create()
failure and returned ERR_PTR(-ENOMEM) but obviously the auxiliary_device_create() and devm_auxiliary_device_create() functions should return the same thing, NULL.

 drivers/base/auxiliary.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Thanks,