[PATCH] drm/amd/amdgpu/amdgpu_ring: match type used for loop counting

Joshua Peisach itzswirlz2020 at outlook.com
Thu Aug 17 19:42:12 UTC 2023


The argument passed to _insert_nop is a uint32_t, and the loop
counts to a regular integer. In the event of the argument being
larger than the maximum integer size, the regular integer would
become negative, and never reach the count number.

So, match the type to prevent an infinite loop.

Signed-off-by: Joshua Peisach <itzswirlz2020 at outlook.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
index 80d6e132e..273894441 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
@@ -108,7 +108,7 @@ int amdgpu_ring_alloc(struct amdgpu_ring *ring, unsigned int ndw)
  */
 void amdgpu_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count)
 {
-       int i;
+       u32 i;
 
        for (i = 0; i < count; i++)
                amdgpu_ring_write(ring, ring->funcs->nop);
-- 
2.41.0


More information about the amd-gfx mailing list