Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

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>

authored by

Anastasia Belova and committed by
Viresh Kumar
f661017e f21401ca

+2
+2
drivers/cpufreq/brcmstb-avs-cpufreq.c
··· 481 481 static unsigned int brcm_avs_cpufreq_get(unsigned int cpu) 482 482 { 483 483 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); 484 + if (!policy) 485 + return 0; 484 486 struct private_data *priv = policy->driver_data; 485 487 486 488 cpufreq_cpu_put(policy);