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

[ Upstream commit f661017e6d326ee187db24194cabb013d81bc2a6 ]

CVE-2024-27051

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>
Signed-off-by: Huang Cun <cunhuang@tencent.com>
Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
This commit is contained in:
Anastasia Belova 2024-01-17 10:12:20 +03:00 committed by Jianping Liu
parent 8f1fe152c9
commit cf271d5d7d
1 changed files with 2 additions and 0 deletions

View File

@ -453,6 +453,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;
return brcm_avs_get_frequency(priv->base);