]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
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)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:21:49 +0000 (18:21 -0400)
[ Upstream commit f661017e6d326ee187db24194cabb013d81bc2a6 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/cpufreq/brcmstb-avs-cpufreq.c

index f644c5e325fb2def542ce0e9000ec2ba1c040130..38ec0fedb247f676fde13cd821cb0284ae193f69 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);