Skip to content

Commit 28dd788

Browse files
AlexiousLualexdeucher
authored andcommitted
drivers/amd/pm: fix a use-after-free in kv_parse_power_table
When ps allocated by kzalloc equals to NULL, kv_parse_power_table frees adev->pm.dpm.ps that allocated before. However, after the control flow goes through the following call chains: kv_parse_power_table |-> kv_dpm_init |-> kv_dpm_sw_init |-> kv_dpm_fini The adev->pm.dpm.ps is used in the for loop of kv_dpm_fini after its first free in kv_parse_power_table and causes a use-after-free bug. Fixes: a2e73f5 ("drm/amdgpu: Add support for CIK parts") Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent ac16667 commit 28dd788

File tree

1 file changed

+1
-3
lines changed
  • drivers/gpu/drm/amd/pm/legacy-dpm

1 file changed

+1
-3
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2735,10 +2735,8 @@ static int kv_parse_power_table(struct amdgpu_device *adev)
27352735
non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *)
27362736
&non_clock_info_array->nonClockInfo[non_clock_array_index];
27372737
ps = kzalloc(sizeof(struct kv_ps), GFP_KERNEL);
2738-
if (ps == NULL) {
2739-
kfree(adev->pm.dpm.ps);
2738+
if (ps == NULL)
27402739
return -ENOMEM;
2741-
}
27422740
adev->pm.dpm.ps[i].ps_priv = ps;
27432741
k = 0;
27442742
idx = (u8 *)&power_state->v2.clockInfoIndex[0];

0 commit comments

Comments
 (0)