Skip to content

Commit b51eb08

Browse files
Jinjie Ruanvireshk
authored andcommitted
cpufreq: CPPC: Fix wrong return value in cppc_get_cpu_power()
cppc_get_cpu_power() return 0 if the policy is NULL. Then in em_create_perf_table(), the later zero check for power is not valid as power is uninitialized. As Quentin pointed out, kernel energy model core check the return value of active_power() first, so if the callback failed it should tell the core. So return -EINVAL to fix it. Fixes: a78e720 ("cpufreq: CPPC: Fix possible null-ptr-deref for cpufreq_cpu_get_raw()") Signed-off-by: Jinjie Ruan <[email protected]> Suggested-by: Quentin Perret <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent be392aa commit b51eb08

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/cpufreq/cppc_cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ static int cppc_get_cpu_power(struct device *cpu_dev,
405405

406406
policy = cpufreq_cpu_get_raw(cpu_dev->id);
407407
if (!policy)
408-
return 0;
408+
return -EINVAL;
409409

410410
cpu_data = policy->driver_data;
411411
perf_caps = &cpu_data->perf_caps;

0 commit comments

Comments
 (0)