cpufreq/amd-pstate: Add missing NULL ptr check in amd_pstate_update

commit 426db24d4d upstream.

Check if policy is NULL before dereferencing it in amd_pstate_update.

Fixes: e8f555daac ("cpufreq/amd-pstate: fix setting policy current frequency value")
Signed-off-by: Dhananjay Ugwekar <dhananjay.ugwekar@amd.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
Link: https://lore.kernel.org/r/20250205112523.201101-11-dhananjay.ugwekar@amd.com
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
[Minor context change fixed.]
Signed-off-by: Wenshan Lan <jetlan9@163.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Dhananjay Ugwekar 2025-02-05 11:25:21 +00:00 committed by Greg Kroah-Hartman
parent 44b25cc825
commit 82b6dfff0d

View File

@ -482,6 +482,9 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf,
u32 nominal_perf = READ_ONCE(cpudata->nominal_perf);
u64 value = prev;
if (!policy)
return;
min_perf = clamp_t(unsigned long, min_perf, cpudata->min_limit_perf,
cpudata->max_limit_perf);
max_perf = clamp_t(unsigned long, max_perf, cpudata->min_limit_perf,