[PATCH] cpufreq: brcmstb-avs-cpufreq: add check for cpufreq_cpu_get's return value

Viresh Kumar viresh.kumar at linaro.org
Mon Jan 22 22:07:28 PST 2024


On 17-01-24, 10:12, Anastasia Belova wrote:
> cpufreq_cpu_get may return NULL. To avoid NULL-dereference check it
> and return 0 in case of error.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: de322e085995 ("cpufreq: brcmstb-avs-cpufreq: AVS CPUfreq driver for Broadcom STB SoCs")
> Signed-off-by: Anastasia Belova <abelova at astralinux.ru>
> ---
>  drivers/cpufreq/brcmstb-avs-cpufreq.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/cpufreq/brcmstb-avs-cpufreq.c b/drivers/cpufreq/brcmstb-avs-cpufreq.c
> index 35fb3a559ea9..1a1857b0a6f4 100644
> --- a/drivers/cpufreq/brcmstb-avs-cpufreq.c
> +++ b/drivers/cpufreq/brcmstb-avs-cpufreq.c
> @@ -481,6 +481,8 @@ static bool brcm_avs_is_firmware_loaded(struct private_data *priv)
>  static unsigned int brcm_avs_cpufreq_get(unsigned int cpu)
>  {
>  	struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
> +	if (!policy)
> +		return 0;
>  	struct private_data *priv = policy->driver_data;
>  
>  	cpufreq_cpu_put(policy);

Applied. Thanks.

-- 
viresh



More information about the linux-arm-kernel mailing list