Skip to contentSkip to conversation

cpufreq: apple-soc: Fix an IS_ERR() vs NULL check

PATCH Applied Dan Carpenter 3 participants 3 messages Feb 27, 2023 – Mar 1, 2023

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

PATCH 1/1 cpufreq: apple-soc: Fix an IS_ERR() vs NULL check

The of_iomap() function returns NULL if it fails. It never returns error pointers. Fix the check accordingly.

Fixes 6286bbb40576 ("cpufreq: apple-soc: Add new driver to control Apple SoC CPU P-states")
---
 drivers/cpufreq/apple-soc-cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/apple-soc-cpufreq.c +2 -2
index c11d22fd84c3..021f423705e1 100644
@@ -189,8 +189,8 @@ static int apple_soc_cpufreq_find_cluster(struct cpufreq_policy *policy,
 	*info = match->data;
 
 	*reg_base = of_iomap(args.np, 0);
-	if (IS_ERR(*reg_base))
-		return PTR_ERR(*reg_base);
+	if (!*reg_base)
+		return -ENOMEM;
 
 	return 0;
 }
Signature · 1 line
2.39.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Dan Carpenter

The of_iomap() function returns NULL if it fails. It never returns error pointers. Fix the check accordingly.

Fixes 6286bbb40576 ("cpufreq: apple-soc: Add new driver to control Apple SoC CPU P-states")

---

Nice catch!

Is mise le meas/Regards,

Eric Curtin

Quoted 22 lines
 drivers/cpufreq/apple-soc-cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/apple-soc-cpufreq.c +2 -3
index c11d22fd84c3..021f423705e1 100644
@@ -189,8 +189,8 @@ static int apple_soc_cpufreq_find_cluster(struct cpufreq_policy *policy,
        *info = match->data;
 
        *reg_base = of_iomap(args.np, 0);
-       if (IS_ERR(*reg_base))
-               return PTR_ERR(*reg_base);
+       if (!*reg_base)
+               return -ENOMEM;
 
        return 0;
 }
--

2.39.1

maintainer Applied
#2 lore raw
Quoted 6 lines · Eric Curtin
Quoted 4 lines · Dan Carpenter

The of_iomap() function returns NULL if it fails. It never returns error pointers. Fix the check accordingly.

Quoted 7 lines
Quoted 3 lines
Fixes 6286bbb40576 ("cpufreq: apple-soc: Add new driver to control Apple SoC CPU P-states")

---

Nice catch!

Applied as 6.3-rc material, thanks!