Skip to contentSkip to conversation

cpufreq: spear: Fix an IS_ERR() vs NULL bug in spear1340_set_cpu_rate()

PATCH Applied Dan Carpenter 3 participants 3 messages Jul 14 – Jul 15

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

PATCH v2 1/1 cpufreq: spear: Fix an IS_ERR() vs NULL bug in spear1340_set_cpu_rate()

The clk_get_parent() function doesn't return error pointers, it returns NULL on error. Update the error checking to match.

Fixes 420993221175 ("cpufreq: SPEAr: Add CPUFreq driver")

---
v2: fix subsystem prefix in subject

 drivers/cpufreq/spear-cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/spear-cpufreq.c +2 -2
index 81a0780b2ebf..ffe5eda82f0b 100644
@@ -79,9 +79,9 @@ static int spear1340_set_cpu_rate(struct clk *sys_pclk, unsigned long newfreq)
 	int ret = 0;
 
 	sys_clk = clk_get_parent(spear_cpufreq.clk);
-	if (IS_ERR(sys_clk)) {
+	if (!sys_clk) {
 		pr_err("failed to get cpu's parent (sys) clock\n");
-		return PTR_ERR(sys_clk);
+		return -EINVAL;
 	}
 
 	/* Set the rate of the source clock before changing the parent */
Signature · 1 line
2.53.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Dan Carpenter

The clk_get_parent() function doesn't return error pointers, it returns NULL on error. Update the error checking to match.

Fixes 420993221175 ("cpufreq: SPEAr: Add CPUFreq driver")

---
v2: fix subsystem prefix in subject

Quoted 20 lines
  drivers/cpufreq/spear-cpufreq.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/spear-cpufreq.c +2 -2
index 81a0780b2ebf..ffe5eda82f0b 100644
@@ -79,9 +79,9 @@ static int spear1340_set_cpu_rate(struct clk *sys_pclk, unsigned long newfreq)
  	int ret = 0;
 
  	sys_clk = clk_get_parent(spear_cpufreq.clk);
-	if (IS_ERR(sys_clk)) {
+	if (!sys_clk) {
  		pr_err("failed to get cpu's parent (sys) clock\n");
-		return PTR_ERR(sys_clk);
+		return -EINVAL;
  	}
 
  	/* Set the rate of the source clock before changing the parent */
Signature · 2 lines
Thx and BRs,
Zhongqiu Han
maintainer Applied
#2 lore raw
Quoted 10 lines · Zhongqiu Han
Quoted 7 lines · Dan Carpenter

The clk_get_parent() function doesn't return error pointers, it returns NULL on error. Update the error checking to match.

Fixes 420993221175 ("cpufreq: SPEAr: Add CPUFreq driver")

---
v2: fix subsystem prefix in subject

Applied. Thanks.

Signature · 1 line
viresh