Skip to contentSkip to conversation

drm/amd/amdgpu: Fix out of bounds warning in amdgpu_hw_ip_info

PATCH In review [email protected] 2 participants 2 messages Apr 11, 2025

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

PATCH 1/1 drm/amd/amdgpu: Fix out of bounds warning in amdgpu_hw_ip_info

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: a245daf3d7a143fb2df(drm/amdgpu: cleanup HW_IP query).

---
 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
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · On Fri, Apr 11, 2025 at 4:23 AM [email protected] <[email protected]> wrote:

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: a245daf3d7a143fb2df(drm/amdgpu: cleanup HW_IP query).

Fixes 4310acd4464b ("drm/amdgpu: add ring flag for no user submissions")
Quoted 22 lines
---
 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 -2
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;
--

2.25.1