Skip to content

Commit 2f3be3c

Browse files
AlexiousLualexdeucher
authored andcommitted
drm/amd/pm/smu7: fix a memleak in smu7_hwmgr_backend_init
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: 599a7e9 ("drm/amd/powerplay: implement smu7 hwmgr to manager asics with smu ip version 7.") Fixes: 8f0804c ("drm/amd/pm: add edc leakage controller setting") Signed-off-by: Zhipeng Lu <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent b1a428b commit 2f3be3c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2974,6 +2974,8 @@ static int smu7_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
29742974
result = smu7_get_evv_voltages(hwmgr);
29752975
if (result) {
29762976
pr_info("Get EVV Voltage Failed. Abort Driver loading!\n");
2977+
kfree(hwmgr->backend);
2978+
hwmgr->backend = NULL;
29772979
return -EINVAL;
29782980
}
29792981
} else {
@@ -3019,8 +3021,10 @@ static int smu7_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
30193021
}
30203022

30213023
result = smu7_update_edc_leakage_table(hwmgr);
3022-
if (result)
3024+
if (result) {
3025+
smu7_hwmgr_backend_fini(hwmgr);
30233026
return result;
3027+
}
30243028

30253029
return 0;
30263030
}

0 commit comments

Comments
 (0)