]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/amd/pm/smu7: fix a memleak in smu7_hwmgr_backend_init
authorZhipeng Lu <alexious@zju.edu.cn>
Sun, 24 Dec 2023 08:22:47 +0000 (16:22 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 5 Jan 2024 21:10:43 +0000 (16:10 -0500)
The hwmgr->backend, (i.e. data) allocated by kzalloc is not freed in
the error-handling paths of smu7_get_evv_voltages and
smu7_update_edc_leakage_table. However, it did be freed in the
error-handling of phm_initializa_dynamic_state_adjustment_rule_settings,
by smu7_hwmgr_backend_fini. So the lack of free in smu7_get_evv_voltages
and smu7_update_edc_leakage_table is considered a memleak in this patch.

Fixes: 599a7e9fe1b6 ("drm/amd/powerplay: implement smu7 hwmgr to manager asics with smu ip version 7.")
Fixes: 8f0804c6b7d0 ("drm/amd/pm: add edc leakage controller setting")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c

index 11372fcc59c8fe8daa93c750b779f8a9d0bbe3bf..b1a8799e2dee320390d239c6242600d4d30cdc39 100644 (file)
@@ -2974,6 +2974,8 @@ static int smu7_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
                result = smu7_get_evv_voltages(hwmgr);
                if (result) {
                        pr_info("Get EVV Voltage Failed.  Abort Driver loading!\n");
+                       kfree(hwmgr->backend);
+                       hwmgr->backend = NULL;
                        return -EINVAL;
                }
        } else {
@@ -3019,8 +3021,10 @@ static int smu7_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
        }
 
        result = smu7_update_edc_leakage_table(hwmgr);
-       if (result)
+       if (result) {
+               smu7_hwmgr_backend_fini(hwmgr);
                return result;
+       }
 
        return 0;
 }