Skip to content

Commit a78e720

Browse files
Jinjie Ruanvireshk
authored andcommitted
cpufreq: CPPC: Fix possible null-ptr-deref for cpufreq_cpu_get_raw()
cpufreq_cpu_get_raw() may return NULL if the cpu is not in policy->cpus cpu mask and it will cause null pointer dereference. Fixes: 740fcdc ("cpufreq: CPPC: Register EM based on efficiency class information") Signed-off-by: Jinjie Ruan <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent 96b9764 commit a78e720

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/cpufreq/cppc_cpufreq.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@ static int cppc_get_cpu_power(struct device *cpu_dev,
404404
struct cppc_cpudata *cpu_data;
405405

406406
policy = cpufreq_cpu_get_raw(cpu_dev->id);
407+
if (!policy)
408+
return 0;
409+
407410
cpu_data = policy->driver_data;
408411
perf_caps = &cpu_data->perf_caps;
409412
max_cap = arch_scale_cpu_capacity(cpu_dev->id);

0 commit comments

Comments
 (0)