Skip to content

Commit ac16667

Browse files
AlexiousLualexdeucher
authored andcommitted
drm/amd/pm: fix a double-free in si_dpm_init
When the allocation of adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries fails, amdgpu_free_extended_power_table is called to free some fields of adev. However, when the control flow returns to si_dpm_sw_init, it goes to label dpm_failed and calls si_dpm_fini, which calls amdgpu_free_extended_power_table again and free those fields again. Thus a double-free is triggered. Fixes: 841686d ("drm/amdgpu: add SI DPM support (v4)") Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 804c49e commit ac16667

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

  • drivers/gpu/drm/amd/pm/legacy-dpm

drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7379,10 +7379,9 @@ static int si_dpm_init(struct amdgpu_device *adev)
73797379
kcalloc(4,
73807380
sizeof(struct amdgpu_clock_voltage_dependency_entry),
73817381
GFP_KERNEL);
7382-
if (!adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
7383-
amdgpu_free_extended_power_table(adev);
7382+
if (!adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries)
73847383
return -ENOMEM;
7385-
}
7384+
73867385
adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.count = 4;
73877386
adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].clk = 0;
73887387
adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].v = 0;

0 commit comments

Comments
 (0)