[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20241106182000.40167-2-abelova@astralinux.ru>
Date: Wed, 6 Nov 2024 21:19:58 +0300
From: Anastasia Belova <abelova@...ralinux.ru>
To: stable@...r.kernel.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Anastasia Belova <abelova@...ralinux.ru>,
lvc-project@...uxtesting.org,
Huang Rui <ray.huang@....com>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Viresh Kumar <viresh.kumar@...aro.org>,
linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org,
Perry Yuan <perry.yuan@....com>
Subject: [PATCH 6.6 1/1] cpufreq: amd-pstate: add check for cpufreq_cpu_get's return value
From: Anastasia Belova <abelova@...ralinux.ru>
commit 5493f9714e4cdaf0ee7cec15899a231400cb1a9f upstream.
cpufreq_cpu_get may return NULL. To avoid NULL-dereference check it
and return in case of error.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Anastasia Belova <abelova@...ralinux.ru>
Reviewed-by: Perry Yuan <perry.yuan@....com>
Signed-off-by: Viresh Kumar <viresh.kumar@...aro.org>
---
drivers/cpufreq/amd-pstate.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 8c16d67b98bf..0fc5495c935a 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -579,9 +579,14 @@ static void amd_pstate_adjust_perf(unsigned int cpu,
unsigned long max_perf, min_perf, des_perf,
cap_perf, lowest_nonlinear_perf, max_freq;
struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
- struct amd_cpudata *cpudata = policy->driver_data;
+ struct amd_cpudata *cpudata;
unsigned int target_freq;
+ if (!policy)
+ return;
+
+ cpudata = policy->driver_data;
+
if (policy->min != cpudata->min_limit_freq || policy->max != cpudata->max_limit_freq)
amd_pstate_update_min_max_limit(policy);
--
2.47.0
Powered by blists - more mailing lists