Skip to contentSkip to conversation

drm/amd/pm: fix memleak of dpm_policies on smu v15

PATCH In review Yang Wang 2 participants 2 messages May 9

Subsystems (3)
lore
Share & tools
lore

Yang Wang

author
#0 lore raw

PATCH 1/1 drm/amd/pm: fix memleak of dpm_policies on smu v15

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 46a072ff8ee6 ("drm/amd/pm: Add initial support for smu v15_0_8");
---
 drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c +2 -0
index 4f0c94821e3f..4a61e900131f 100644
@@ -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;
Signature · 1 line
2.47.3
Reviewed-by on v1 1/1
#1 lore raw

AMD General

Thanks & Regards
Asad

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Yang Wang
Sent: Saturday, May 9, 2026 12:56 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: [PATCH] drm/amd/pm: fix memleak of dpm_policies on smu v15

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 46a072ff8ee6 ("drm/amd/pm: Add initial support for smu v15_0_8");
---
 drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c +2 -0
index 4f0c94821e3f..4a61e900131f 100644
@@ -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;

--
2.47.3