Skip to content

Commit

Permalink
cpufreq: amd-pstate: fix memory leak on CPU EPP exit
Browse files Browse the repository at this point in the history
The cpudata memory from kzalloc() in amd_pstate_epp_cpu_init() is
not freed in the analogous exit function, so fix that.

Signed-off-by: Peng Ma <andypma@tencent.com>
Acked-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Perry Yuan <Perry.Yuan@amd.com>
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Peng Ma authored and Rafael J. Wysocki committed May 16, 2024
1 parent 0c181b1 commit cea04f3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/cpufreq/amd-pstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,13 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)

static int amd_pstate_epp_cpu_exit(struct cpufreq_policy *policy)
{
struct amd_cpudata *cpudata = policy->driver_data;

if (cpudata) {
kfree(cpudata);
policy->driver_data = NULL;
}

pr_debug("CPU %d exiting\n", policy->cpu);
return 0;
}
Expand Down

0 comments on commit cea04f3

Please sign in to comment.