cpufreq: brcmstb-avs-cpufreq: add check for cpufreq_cpu_get's return value
authorAnastasia Belova <abelova@astralinux.ru>
Wed, 17 Jan 2024 07:12:20 +0000 (10:12 +0300)
committerViresh Kumar <viresh.kumar@linaro.org>
Tue, 23 Jan 2024 06:07:14 +0000 (11:37 +0530)
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@astralinux.ru>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
drivers/cpufreq/brcmstb-avs-cpufreq.c

index 35fb3a559ea97b835931317853bd52d8a96ea6f1..1a1857b0a6f482d4e07a9c4a58ff66bb5d98cebd 100644 (file)
@@ -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);