Skip to contentSkip to conversation

drm/amd/amdgpu: Fix array bounds check in amdgpu_hw_ip_info

PATCH New [email protected] 1 participant 1 message Apr 11, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/amd/amdgpu: Fix array bounds check in amdgpu_hw_ip_info

From: "[email protected]" <[email protected]>

Fix an array index out of bounds warning in the DMA IP case of amdgpu_hw_ip_info() where it was incorrectly checking adev->gfx.gfx_ring[i].no_user_submission instead of adev->sdma.instance[i].ring.no_user_submission.

The mismatch caused UBSAN to report an array bounds violation since it was accessing the GFX ring array with SDMA instance indices.

Fix the commit: de412e03405f6a50(drm/amdgpu: add ring flag for no user submissions).

v2: update the commit message.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -1
index 0ba3ef1e4a06..6a42dea775b1 100644
@@ -427,7 +427,7 @@ static int amdgpu_hw_ip_info(struct amdgpu_device *adev,
 		type = AMD_IP_BLOCK_TYPE_SDMA;
 		for (i = 0; i < adev->sdma.num_instances; i++)
 			if (adev->sdma.instance[i].ring.sched.ready &&
-			    !adev->gfx.gfx_ring[i].no_user_submission)
+			    !adev->sdma.instance[i].ring.no_user_submission)
 				++num_rings;
 		ib_start_alignment = 256;
 		ib_size_alignment = 4;
Signature · 1 line
2.25.1