Skip to content

Commit 73b24dc

Browse files
Henry Martinvireshk
authored andcommitted
cpufreq: scpi: Fix null-ptr-deref in scpi_cpufreq_get_rate()
cpufreq_cpu_get_raw() can return NULL when the target CPU is not present in the policy->cpus mask. scpi_cpufreq_get_rate() does not check for this case, which results in a NULL pointer dereference. Fixes: 343a8d1 ("cpufreq: scpi: remove arm_big_little dependency") Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com> Acked-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent 484d3f1 commit 73b24dc

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/cpufreq/scpi-cpufreq.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,16 @@ static struct scpi_ops *scpi_ops;
2929

3030
static unsigned int scpi_cpufreq_get_rate(unsigned int cpu)
3131
{
32-
struct cpufreq_policy *policy = cpufreq_cpu_get_raw(cpu);
33-
struct scpi_data *priv = policy->driver_data;
34-
unsigned long rate = clk_get_rate(priv->clk);
32+
struct cpufreq_policy *policy;
33+
struct scpi_data *priv;
34+
unsigned long rate;
35+
36+
policy = cpufreq_cpu_get_raw(cpu);
37+
if (unlikely(!policy))
38+
return 0;
39+
40+
priv = policy->driver_data;
41+
rate = clk_get_rate(priv->clk);
3542

3643
return rate / 1000;
3744
}

0 commit comments

Comments
 (0)