[PATCH] cpufreq: scpi: Prevent null pointer dereference in scpi_cpufreq_get_rate()
Viresh Kumar
viresh.kumar at linaro.org
Wed Jan 1 21:00:10 PST 2025
On 30-12-24, 17:31, Charles Han wrote:
> cpufreq_cpu_get_raw() may return NULL if the cpu is not in
> policy->cpus cpu mask and it will cause null pointer dereference.
> Prevent null pointer dereference in scpi_cpufreq_get_rate().
>
> Fixes: 343a8d17fa8d ("cpufreq: scpi: remove arm_big_little dependency")
> Signed-off-by: Charles Han <hanchunchao at inspur.com>
> ---
> drivers/cpufreq/scpi-cpufreq.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/cpufreq/scpi-cpufreq.c b/drivers/cpufreq/scpi-cpufreq.c
> index cd89c1b9832c..c888ed3a0de9 100644
> --- a/drivers/cpufreq/scpi-cpufreq.c
> +++ b/drivers/cpufreq/scpi-cpufreq.c
> @@ -30,6 +30,9 @@ static struct scpi_ops *scpi_ops;
> static unsigned int scpi_cpufreq_get_rate(unsigned int cpu)
> {
> struct cpufreq_policy *policy = cpufreq_cpu_get_raw(cpu);
> + if (unlikely(!policy))
> + return 0;
> +
> struct scpi_data *priv = policy->driver_data;
> unsigned long rate = clk_get_rate(priv->clk);
The check needs to be made after all the variable definitions.
--
viresh
More information about the linux-arm-kernel
mailing list