Skip to contentSkip to conversation

pmdomain: thead: Fix error pointer vs NULL bug in th1520_pd_reboot_init()

PATCH In review Dan Carpenter 3 participants 3 messages Sep 26, 2025

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

PATCH 1/1 pmdomain: thead: Fix error pointer vs NULL bug in th1520_pd_reboot_init()

The devm_auxiliary_device_create() returns NULL on error. It never returns error pointers. Using PTR_ERR_OR_ZERO() here means the function always returns success. Replace the PTR_ERR_OR_ZERO() call check with a NULL check.

Fixes 64581f41f4c4 ("pmdomain: thead: create auxiliary device for rebooting")
---
 drivers/pmdomain/thead/th1520-pm-domains.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pmdomain/thead/th1520-pm-domains.c +3 -1
index 5213994101a5..d7cb9633c7c8 100644
@@ -179,8 +179,10 @@ static int th1520_pd_reboot_init(struct device *dev,
 	struct auxiliary_device *adev;
 
 	adev = devm_auxiliary_device_create(dev, "reboot", aon_chan);
+	if (!adev)
+		return -ENODEV;
 
-	return PTR_ERR_OR_ZERO(adev);
+	return 0;
 }
 
 static int th1520_pd_probe(struct platform_device *pdev)
Signature · 1 line
2.51.0
#1 lore raw
Quoted 2 lines · 在 2025-09-26星期五的 07:03 +0300,Dan Carpenter写道:

The devm_auxiliary_device_create() returns NULL on error.  It never returns error pointers.  Using PTR_ERR_OR_ZERO() here means the

Checked the implementation of auxiliary devices, and this is true.

So

```
Acked-by: Icenowy Zheng <[email protected]>
```
Quoted 31 lines

function
always returns success.  Replace the PTR_ERR_OR_ZERO() call check with
a NULL check.

Fixes 64581f41f4c4 ("pmdomain: thead: create auxiliary device for

rebooting")

---
 drivers/pmdomain/thead/th1520-pm-domains.c | 4 +++-

 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pmdomain/thead/th1520-pm-domains.c +0 -0
index 5213994101a5..d7cb9633c7c8 100644
@@ -179,8 +179,10 @@ static int th1520_pd_reboot_init(struct device
 *dev,
         struct auxiliary_device *adev;


        adev = devm_auxiliary_device_create(dev, "reboot", aon_chan); +       if (!adev)
+               return -ENODEV;


-       return PTR_ERR_OR_ZERO(adev);
+       return 0;
 }

 static int th1520_pd_probe(struct platform_device *pdev)

#2 lore raw
In reply to Dan Carpenter
Quoted 8 lines · Dan Carpenter

The devm_auxiliary_device_create() returns NULL on error. It never returns error pointers. Using PTR_ERR_OR_ZERO() here means the function always returns success. Replace the PTR_ERR_OR_ZERO() call check with a NULL check.

Fixes 64581f41f4c4 ("pmdomain: thead: create auxiliary device for rebooting")

Applied for next, thanks!

Kind regards
Uffe

Quoted 23 lines
---
 drivers/pmdomain/thead/th1520-pm-domains.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pmdomain/thead/th1520-pm-domains.c +3 -2
index 5213994101a5..d7cb9633c7c8 100644
@@ -179,8 +179,10 @@ static int th1520_pd_reboot_init(struct device *dev,
        struct auxiliary_device *adev;
 
        adev = devm_auxiliary_device_create(dev, "reboot", aon_chan);
+       if (!adev)
+               return -ENODEV;
 
-       return PTR_ERR_OR_ZERO(adev);
+       return 0;
 }
 
 static int th1520_pd_probe(struct platform_device *pdev)
--

2.51.0