Skip to contentSkip to conversation

powercap: intel_rapl: Fix a NULL vs IS_ERR() bug

PATCH Applied Dan Carpenter 3 participants 3 messages Jun 6, 2023 – Jun 12, 2023

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

PATCH 1/1 powercap: intel_rapl: Fix a NULL vs IS_ERR() bug

The devm_ioremap_resource() function returns error pointers on error, it never returns NULL. Update the check accordingly.

Fixes 9eef7f9da928 ("powercap: intel_rapl: Introduce RAPL TPMI interface driver")
---
 drivers/powercap/intel_rapl_tpmi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/powercap/intel_rapl_tpmi.c +2 -2
index c016127b3497..4f4f13ded225 100644
@@ -255,8 +255,8 @@ static int intel_rapl_tpmi_probe(struct auxiliary_device *auxdev,
 	}
 
 	trp->base = devm_ioremap_resource(&auxdev->dev, res);
-	if (!trp->base) {
-		ret = -ENOMEM;
+	if (IS_ERR(trp->base)) {
+		ret = PTR_ERR(trp->base);
 		goto err;
 	}
 
Signature · 1 line
2.39.2
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dan Carpenter

The devm_ioremap_resource() function returns error pointers on error, it never returns NULL.  Update the check accordingly.

Fixes 9eef7f9da928 ("powercap: intel_rapl: Introduce RAPL TPMI

interface driver")

thanks,
rui

Quoted 21 lines

---
 drivers/powercap/intel_rapl_tpmi.c | 4 ++--

 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/powercap/intel_rapl_tpmi.c +0 -0
index c016127b3497..4f4f13ded225 100644
@@ -255,8 +255,8 @@ static int intel_rapl_tpmi_probe(struct
 auxiliary_device *auxdev,
         }


        trp->base = devm_ioremap_resource(&auxdev->dev, res); -       if (!trp->base) {
-               ret = -ENOMEM;
+       if (IS_ERR(trp->base)) {
+               ret = PTR_ERR(trp->base);
                goto err;
        }

maintainer Applied
#2 lore raw
Quoted 10 lines · Rui
Quoted 6 lines · Dan Carpenter

The devm_ioremap_resource() function returns error pointers on error, it never returns NULL. Update the check accordingly.

Fixes 9eef7f9da928 ("powercap: intel_rapl: Introduce RAPL TPMI

interface driver")

Applied as 6.5 material, thanks!

Quoted 22 lines
Quoted 21 lines
---
 drivers/powercap/intel_rapl_tpmi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/powercap/intel_rapl_tpmi.c +2 -2
index c016127b3497..4f4f13ded225 100644
@@ -255,8 +255,8 @@ static int intel_rapl_tpmi_probe(struct
 auxiliary_device *auxdev,
        }
 
        trp->base = devm_ioremap_resource(&auxdev->dev, res);
-       if (!trp->base) {
-               ret = -ENOMEM;
+       if (IS_ERR(trp->base)) {
+               ret = PTR_ERR(trp->base);
                goto err;
        }