Skip to content

Commit 3ace200

Browse files
dhananjay-AMDsuperm1
authored andcommitted
cpufreq/amd-pstate: Fix cpufreq_policy ref counting
amd_pstate_update_limits() takes a cpufreq_policy reference but doesn't decrement the refcount in one of the exit paths, fix that. Fixes: 45722e7 ("cpufreq: amd-pstate: Optimize amd_pstate_update_limits()") Signed-off-by: Dhananjay Ugwekar <dhananjay.ugwekar@amd.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Link: https://lore.kernel.org/r/20250205112523.201101-10-dhananjay.ugwekar@amd.com Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
1 parent 55db9b7 commit 3ace200

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -821,20 +821,21 @@ static void amd_pstate_init_prefcore(struct amd_cpudata *cpudata)
821821

822822
static void amd_pstate_update_limits(unsigned int cpu)
823823
{
824-
struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
824+
struct cpufreq_policy *policy = NULL;
825825
struct amd_cpudata *cpudata;
826826
u32 prev_high = 0, cur_high = 0;
827827
int ret;
828828
bool highest_perf_changed = false;
829829

830+
if (!amd_pstate_prefcore)
831+
return;
832+
833+
policy = cpufreq_cpu_get(cpu);
830834
if (!policy)
831835
return;
832836

833837
cpudata = policy->driver_data;
834838

835-
if (!amd_pstate_prefcore)
836-
return;
837-
838839
guard(mutex)(&amd_pstate_driver_lock);
839840

840841
ret = amd_get_highest_perf(cpu, &cur_high);

0 commit comments

Comments
 (0)