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

BugLink: https://bugs.launchpad.net/bugs/2060097

[ 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: de322e0859 ("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>
(cherry picked from commit e6e3e51ffba0784782b1a076d7441605697ea3c6)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
This commit is contained in:
Anastasia Belova
2024-01-17 10:12:20 +03:00
committed by Roxana Nicolescu
parent e2e4bda4f3
commit d1d6e9657b
+2
View 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);