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

Koichiro Den koichiro.den at canonical.com
Tue Sep 10 11:25:43 UTC 2024


From: Anastasia Belova <abelova at astralinux.ru>

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>
Signed-off-by: Viresh Kumar <viresh.kumar at linaro.org>
(backported from f661017e6d326ee187db24194cabb013d81bc2a6)
[koichiroden: Adjusted context due to missing commit a48ac1c9f294
 ("cpufreq: brcmstb-avs: fix imbalance of cpufreq policy refcount")]
CVE-2024-27051
Signed-off-by: Koichiro Den <koichiro.den at canonical.com>
---
 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 541486217984..1302e1900dcb 100644
--- a/drivers/cpufreq/brcmstb-avs-cpufreq.c
+++ b/drivers/cpufreq/brcmstb-avs-cpufreq.c
@@ -457,6 +457,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);
-- 
2.43.0




More information about the kernel-team mailing list