Skip to content

Commit 4e36914

Browse files
committed
cpufreq: scpi: Fix null-ptr-deref in scpi_cpufreq_get_rate()
JIRA: https://issues.redhat.com/browse/RHEL-83803 commit 73b24dc Author: Henry Martin <bsdhenrymartin@gmail.com> Date: Thu, 10 Apr 2025 10:09:03 +0000 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> Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
1 parent 237f44a commit 4e36914

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
@@ -37,9 +37,16 @@ static struct scpi_ops *scpi_ops;
3737

3838
static unsigned int scpi_cpufreq_get_rate(unsigned int cpu)
3939
{
40-
struct cpufreq_policy *policy = cpufreq_cpu_get_raw(cpu);
41-
struct scpi_data *priv = policy->driver_data;
42-
unsigned long rate = clk_get_rate(priv->clk);
40+
struct cpufreq_policy *policy;
41+
struct scpi_data *priv;
42+
unsigned long rate;
43+
44+
policy = cpufreq_cpu_get_raw(cpu);
45+
if (unlikely(!policy))
46+
return 0;
47+
48+
priv = policy->driver_data;
49+
rate = clk_get_rate(priv->clk);
4350

4451
return rate / 1000;
4552
}

0 commit comments

Comments
 (0)