From: Dhananjay Ugwekar Date: Wed, 5 Feb 2025 11:25:21 +0000 (+0000) Subject: cpufreq/amd-pstate: Add missing NULL ptr check in amd_pstate_update X-Git-Tag: v6.15-rc1~191^2~4^2~2^2~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=426db24d4db2e4f0d6720aeb7795eafcb9e82640;p=thirdparty%2Fkernel%2Flinux.git cpufreq/amd-pstate: Add missing NULL ptr check in amd_pstate_update Check if policy is NULL before dereferencing it in amd_pstate_update. Fixes: e8f555daacd3 ("cpufreq/amd-pstate: fix setting policy current frequency value") Signed-off-by: Dhananjay Ugwekar Reviewed-by: Mario Limonciello Reviewed-by: Gautham R. Shenoy Link: https://lore.kernel.org/r/20250205112523.201101-11-dhananjay.ugwekar@amd.com Signed-off-by: Mario Limonciello --- diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 9c939be59042d..6a604f0797d9f 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -551,6 +551,9 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u8 min_perf, struct cpufreq_policy *policy = cpufreq_cpu_get(cpudata->cpu); u8 nominal_perf = READ_ONCE(cpudata->nominal_perf); + if (!policy) + return; + des_perf = clamp_t(u8, des_perf, min_perf, max_perf); policy->cur = perf_to_freq(cpudata, des_perf);