This is a note to let you know that I've just added the patch titled cpufreq/amd-pstate: Fix cpufreq_policy ref counting to the 6.13-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: cpufreq-amd-pstate-fix-cpufreq_policy-ref-counting.patch and it can be found in the queue-6.13 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit ebb30c2a945bbaf83c9017b3b89e3e4bd9e74fe1 Author: Dhananjay Ugwekar <dhananjay.ugwekar@xxxxxxx> Date: Wed Feb 5 11:25:20 2025 +0000 cpufreq/amd-pstate: Fix cpufreq_policy ref counting [ Upstream commit 3ace20038e19f23fe73259513f1f08d4bf1a3c83 ] amd_pstate_update_limits() takes a cpufreq_policy reference but doesn't decrement the refcount in one of the exit paths, fix that. Fixes: 45722e777fd9 ("cpufreq: amd-pstate: Optimize amd_pstate_update_limits()") Signed-off-by: Dhananjay Ugwekar <dhananjay.ugwekar@xxxxxxx> Reviewed-by: Mario Limonciello <mario.limonciello@xxxxxxx> Link: https://lore.kernel.org/r/20250205112523.201101-10-dhananjay.ugwekar@xxxxxxx Signed-off-by: Mario Limonciello <mario.limonciello@xxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index bdaa19c25887b..0aea414b8ac4a 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -809,20 +809,21 @@ static void amd_pstate_init_prefcore(struct amd_cpudata *cpudata) static void amd_pstate_update_limits(unsigned int cpu) { - struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); + struct cpufreq_policy *policy = NULL; struct amd_cpudata *cpudata; u32 prev_high = 0, cur_high = 0; int ret; bool highest_perf_changed = false; + if (!amd_pstate_prefcore) + return; + + policy = cpufreq_cpu_get(cpu); if (!policy) return; cpudata = policy->driver_data; - if (!amd_pstate_prefcore) - return; - guard(mutex)(&amd_pstate_driver_lock); ret = amd_get_highest_perf(cpu, &cur_high);