]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/pm: fix memleak of dpm_policies on smu v15
authorYang Wang <kevinyang.wang@amd.com>
Sat, 9 May 2026 07:20:39 +0000 (15:20 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 18 May 2026 22:13:55 +0000 (18:13 -0400)
In smu_v15_0_fini_smc_tables, dpm_policies was not freed or NULLed, causing a memory leak.
Add kfree() and NULL assignment to properly release memory and avoid dangling pointers.

Fixes: 2beedc3a92b7 ("drm/amd/pm: Add initial support for smu v15_0_8");
Signed-off-by: Yang Wang <kevinyang.wang@amd.com>
Reviewed-by: Asad Kamal <asad.kamal@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c

index cc3a265700a5919e68beb1814a0fe8ed7f202934..a1318409e4b5ef0d8ed807eb56e8080eae594b5a 100644 (file)
@@ -435,10 +435,12 @@ int smu_v15_0_fini_smc_tables(struct smu_context *smu)
        smu_table->watermarks_table = NULL;
        smu_table->metrics_time = 0;
 
+       kfree(smu_dpm->dpm_policies);
        kfree(smu_dpm->dpm_context);
        kfree(smu_dpm->golden_dpm_context);
        kfree(smu_dpm->dpm_current_power_state);
        kfree(smu_dpm->dpm_request_power_state);
+       smu_dpm->dpm_policies = NULL;
        smu_dpm->dpm_context = NULL;
        smu_dpm->golden_dpm_context = NULL;
        smu_dpm->dpm_context_size = 0;