Skip to contentSkip to conversation

cpufreq: cppc: Fix invalid return value in .get() callback

PATCH Applied Marc Zyngier 3 participants 3 messages Apr 13, 2025 – Apr 16, 2025

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

PATCH 1/1 cpufreq: cppc: Fix invalid return value in .get() callback

Returning a negative error code in a function with an unsigned return type is a pretty bad idea. It is probably worse when the justification for the change is "our static analisys tool found it".

Fixes cf7de25878a1 ("cppc_cpufreq: Fix possible null pointer dereference")
Cc "Rafael J. Wysocki" <[email protected]>
Cc Viresh Kumar <[email protected]>
---
 drivers/cpufreq/cppc_cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/cppc_cpufreq.c +1 -1
index b3d74f9adcf0b..cb93f00bafdba 100644
@@ -747,7 +747,7 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpu)
 	int ret;
 
 	if (!policy)
-		return -ENODEV;
+		return 0;
 
 	cpu_data = policy->driver_data;
 
Signature · 1 line
2.39.2
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Marc Zyngier

Returning a negative error code in a function with an unsigned return type is a pretty bad idea. It is probably worse when the justification for the change is "our static analisys tool found it".

Fixes cf7de25878a1 ("cppc_cpufreq: Fix possible null pointer dereference")
Cc "Rafael J. Wysocki" <[email protected]>
Cc Viresh Kumar <[email protected]>
---
 drivers/cpufreq/cppc_cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/cppc_cpufreq.c +0 -0
index b3d74f9adcf0b..cb93f00bafdba 100644

drivers/cpufreq/cppc_cpufreq.c static unsigned int cppc_cpufreq_get_rate(unsigned int cpu) · line 753

Quoted 8 lines
drivers/cpufreq/cppc_cpufreq.c +1 -1
@@ -747,7 +747,7 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpu)
 	int ret;
 
 	if (!policy)
-		return -ENODEV;
+		return 0;
 
 	cpu_data = policy->driver_data;
 
maintainer Applied
#2 lore raw
Quoted 8 lines · zhenglifeng (A)
Quoted 7 lines · Marc Zyngier
drivers/cpufreq/cppc_cpufreq.c +0 -0
index b3d74f9adcf0b..cb93f00bafdba 100644
@@ -747,7 +747,7 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpu)
 	int ret;
 
Quoted 8 lines

drivers/cpufreq/cppc_cpufreq.c static unsigned int cppc_cpufreq_get_rate(unsigned int cpu) · line 753

Quoted 6 lines
drivers/cpufreq/cppc_cpufreq.c +1 -1
 	if (!policy)
-		return -ENODEV;
+		return 0;
 
 	cpu_data = policy->driver_data;
 

Applied. Thanks.

Signature · 1 line
viresh