Skip to contentSkip to conversation

drm/amd/pm: Fix a potential gpu_metrics_table memory leak

PATCH In review Zhen Ni 2 participants 3 messages Aug 3, 2022

Subsystems (3)
lore
Share & tools
lore

Zhen Ni

author
#0 lore raw

PATCH 1/2 drm/amd/pm: Fix a potential gpu_metrics_table memory leak

Memory is allocated for gpu_metrics_table in smu_v13_0_4_init_smc_tables(), but not freed in smu_v13_0_4_fini_smc_tables(). This may cause memory leaks, fix it.

---
 drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_4_ppt.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_4_ppt.c +3 -0
index 5a17b51aa0f9..7df360c25d51 100644
@@ -190,6 +190,9 @@ static int smu_v13_0_4_fini_smc_tables(struct smu_context *smu)
 	kfree(smu_table->watermarks_table);
 	smu_table->watermarks_table = NULL;
 
+	kfree(smu_table->gpu_metrics_table);
+	smu_table->gpu_metrics_table = NULL;
+
 	return 0;
 }
 
Signature · 1 line
2.20.1
author
#1 lore raw

PATCH 2/2 drm/amd/pm: Fix a potential gpu_metrics_table memory leak

Memory is allocated for gpu_metrics_table in smu_v13_0_5_init_smc_tables(), but not freed in smu_v13_0_5_fini_smc_tables(). This may cause memory leaks, fix it.

---
 drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_5_ppt.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_5_ppt.c +3 -0
index b81711c4ff33..267c9c43a010 100644
@@ -167,6 +167,9 @@ static int smu_v13_0_5_fini_smc_tables(struct smu_context *smu)
 	kfree(smu_table->watermarks_table);
 	smu_table->watermarks_table = NULL;
 
+	kfree(smu_table->gpu_metrics_table);
+	smu_table->gpu_metrics_table = NULL;
+
 	return 0;
 }
 
Signature · 1 line
2.20.1
#2 lore raw

[AMD Official Use Only - General]

Thanks for the fixes! The series is reviewed-by: Evan Quan <[email protected]>

Evan

Quoted 40 lines

-----Original Message-----
From: Zhen Ni <[email protected]>
Sent: Wednesday, August 3, 2022 5:20 PM
To: [email protected]; [email protected]; Quan, Evan <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; Zhen Ni <[email protected]>
Subject: [PATCH 2/2] drm/amd/pm: Fix a potential gpu_metrics_table memory leak

Memory is allocated for gpu_metrics_table in smu_v13_0_5_init_smc_tables(), but not freed in smu_v13_0_5_fini_smc_tables(). This may cause memory leaks, fix it.

---
 drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_5_ppt.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_5_ppt.c +3 -1
index b81711c4ff33..267c9c43a010 100644
@@ -167,6 +167,9 @@ static int smu_v13_0_5_fini_smc_tables(struct
 smu_context *smu)
 	kfree(smu_table->watermarks_table);
 	smu_table->watermarks_table = NULL;
 
+	kfree(smu_table->gpu_metrics_table);
+	smu_table->gpu_metrics_table = NULL;
+
 	return 0;
 }
 
--

2.20.1