Skip to content

Commit 1a1374b

Browse files
Jinjie Ruanvireshk
authored andcommitted
cpufreq: CPPC: Fix possible null-ptr-deref for cppc_get_cpu_cost()
cpufreq_cpu_get_raw() may return NULL if the cpu is not in policy->cpus cpu mask and it will cause null pointer dereference, so check NULL for cppc_get_cpu_cost(). 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 a78e720 commit 1a1374b

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
@@ -474,6 +474,9 @@ static int cppc_get_cpu_cost(struct device *cpu_dev, unsigned long KHz,
474474
int step;
475475

476476
policy = cpufreq_cpu_get_raw(cpu_dev->id);
477+
if (!policy)
478+
return 0;
479+
477480
cpu_data = policy->driver_data;
478481
perf_caps = &cpu_data->perf_caps;
479482
max_cap = arch_scale_cpu_capacity(cpu_dev->id);

0 commit comments

Comments
 (0)