Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpufreq: amd-pstate: fix memory leak on CPU EPP exit

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>

authored by

Peng Ma and committed by
Rafael J. Wysocki
cea04f3d 0c181b1d

+7
+7
drivers/cpufreq/amd-pstate.c
··· 1441 1441 1442 1442 static int amd_pstate_epp_cpu_exit(struct cpufreq_policy *policy) 1443 1443 { 1444 + struct amd_cpudata *cpudata = policy->driver_data; 1445 + 1446 + if (cpudata) { 1447 + kfree(cpudata); 1448 + policy->driver_data = NULL; 1449 + } 1450 + 1444 1451 pr_debug("CPU %d exiting\n", policy->cpu); 1445 1452 return 0; 1446 1453 }