]> git.ipfire.org Git - thirdparty/linux.git/commit
drm/amd: Fix NULL pointer dereference in device cleanup
authorMario Limonciello <mario.limonciello@amd.com>
Wed, 4 Mar 2026 20:07:40 +0000 (14:07 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 6 Mar 2026 21:25:44 +0000 (16:25 -0500)
commitb7ac77468cda92eecae560b05f62f997a12fe2f2
tree7c1781c48e1f4f24d09fd1392fd7c7c6466c8046
parent576a10797b607ee9e4068218daf367b481564120
drm/amd: Fix NULL pointer dereference in device cleanup

When GPU initialization fails due to an unsupported HW block
IP blocks may have a NULL version pointer. During cleanup in
amdgpu_device_fini_hw, the code calls amdgpu_device_set_pg_state and
amdgpu_device_set_cg_state which iterate over all IP blocks and access
adev->ip_blocks[i].version without NULL checks, leading to a kernel
NULL pointer dereference.

Add NULL checks for adev->ip_blocks[i].version in both
amdgpu_device_set_cg_state and amdgpu_device_set_pg_state to prevent
dereferencing NULL pointers during GPU teardown when initialization has
failed.

Fixes: 39fc2bc4da00 ("drm/amdgpu: Protect GPU register accesses in powergated state in some paths")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c