drm/amd/pm: Fix a potential gpu_metrics_table memory leak
authorZhen Ni <nizhen@uniontech.com>
Wed, 3 Aug 2022 09:19:58 +0000 (17:19 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 10 Aug 2022 19:41:23 +0000 (15:41 -0400)
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.

Reviewed-by: Evan Quan <evan.quan@amd.com>
Signed-off-by: Zhen Ni <nizhen@uniontech.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_4_ppt.c

index 64665e8..97e1d55 100644 (file)
@@ -198,6 +198,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;
 }