cpufreq: amd-pstate: fix memory leak on CPU EPP exit
authorPeng Ma <andypma@tencent.com>
Thu, 16 May 2024 06:30:42 +0000 (14:30 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 16 May 2024 08:38:07 +0000 (10:38 +0200)
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>
drivers/cpufreq/amd-pstate.c

index 6a342b0c014034b06c320f0d0c8b69d3dbc4596c..1b7e82a0ad2e62f4e0f3e520bfa9408888bc4434 100644 (file)
@@ -1441,6 +1441,13 @@ free_cpudata1:
 
 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;
 }