From: jsg Date: Mon, 29 Jan 2024 01:42:34 +0000 (+0000) Subject: drivers/amd/pm: fix a use-after-free in kv_parse_power_table X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=92bc92c87cd7cd1e53876b1c2bc227711f1d5a1c;p=openbsd drivers/amd/pm: fix a use-after-free in kv_parse_power_table From Zhipeng Lu 95084632a65d5c0d682a83b55935560bdcd2a1e3 in linux-6.6.y/6.6.14 28dd788382c43b330480f57cd34cde0840896743 in mainline linux --- diff --git a/sys/dev/pci/drm/amd/pm/legacy-dpm/amdgpu_kv_dpm.c b/sys/dev/pci/drm/amd/pm/legacy-dpm/amdgpu_kv_dpm.c index 5d28c951a31..5cb4725c773 100644 --- a/sys/dev/pci/drm/amd/pm/legacy-dpm/amdgpu_kv_dpm.c +++ b/sys/dev/pci/drm/amd/pm/legacy-dpm/amdgpu_kv_dpm.c @@ -2735,10 +2735,8 @@ static int kv_parse_power_table(struct amdgpu_device *adev) non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *) &non_clock_info_array->nonClockInfo[non_clock_array_index]; ps = kzalloc(sizeof(struct kv_ps), GFP_KERNEL); - if (ps == NULL) { - kfree(adev->pm.dpm.ps); + if (ps == NULL) return -ENOMEM; - } adev->pm.dpm.ps[i].ps_priv = ps; k = 0; idx = (u8 *)&power_state->v2.clockInfoIndex[0];