Skip to contentSkip to conversation

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

PATCH Superseded Dan Carpenter 2 participants 3 messages Apr 23, 2025

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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

The auxiliary_device_create() function returns NULL. It doesn't return error pointers. Update the checking to match.

Fixes eaa0d30216c1 ("driver core: auxiliary bus: add device creation helpers")
---
 drivers/base/auxiliary.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/base/auxiliary.c +2 -2
index 810b6105a75d..61b876d90b7f 100644
@@ -491,8 +491,8 @@ 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 ERR_PTR(-ENOMEM);
 
 	ret = devm_add_action_or_reset(dev, auxiliary_device_destroy,
 				       auxdev);
Signature · 1 line
2.47.2
#1 lore raw
Quoted 5 lines · Dan Carpenter

The auxiliary_device_create() function returns NULL. It doesn't return error pointers. Update the checking to match.

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

Thanks for catching this mistake Dan.

The thing was initially setup to return error code. Greg asked to simply return NULL on error and I forgot to re-align the devm variant.

So I think the fix should be to check for NULL as you did but return NULL too so it is aligned with non-devm variant.

If you wish, I can handle a v2.

Quoted 19 lines
---
 drivers/base/auxiliary.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/base/auxiliary.c +2 -2
index 810b6105a75d..61b876d90b7f 100644
@@ -491,8 +491,8 @@ 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 ERR_PTR(-ENOMEM);
 
 	ret = devm_add_action_or_reset(dev, auxiliary_device_destroy,
 				       auxdev);
Signature · 1 line
Jerome
#2 lore raw
Quoted 10 lines · Jerome Brunet
Quoted 5 lines · Dan Carpenter

The auxiliary_device_create() function returns NULL. It doesn't return error pointers. Update the checking to match.

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

Thanks for catching this mistake Dan.

Quoted 7 lines

The thing was initially setup to return error code. Greg asked to simply return NULL on error and I forgot to re-align the devm variant.

So I think the fix should be to check for NULL as you did but return NULL too so it is aligned with non-devm variant.

If you wish, I can handle a v2.

Of course, it's hard to resist an offer like that but I can send a v2.

regards,
dan carpenter