]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amdgpu/jpeg: Fix sprintf buffer overflow warning in jpeg_v2_5
authorMichal Simek <michal.simek@amd.com>
Tue, 14 Apr 2026 06:02:31 +0000 (08:02 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 17 Apr 2026 19:41:13 +0000 (15:41 -0400)
Replace sprintf() with snprintf() to fix the -Werror=format-overflow
warning when building with allmodconfig:

  drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c:152:47: error: '%d' directive
  writing between 1 and 11 bytes into a region of size 7
  [-Werror=format-overflow=]
    152 |                 sprintf(ring->name, "jpeg_dec_%d", i);

The ring->name buffer is 16 bytes. Using snprintf() with sizeof()
ensures the buffer cannot overflow regardless of the integer value.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Michal Simek <michal.simek@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c

index 20983f126b4907f226f02fb662336dcebff8e598..fe2b049afac3ac00f41d463c4afdcea5132e9ed8 100644 (file)
@@ -149,7 +149,7 @@ static int jpeg_v2_5_sw_init(struct amdgpu_ip_block *ip_block)
                else
                        ring->vm_hub = AMDGPU_MMHUB0(0);
                ring->doorbell_index = (adev->doorbell_index.vcn.vcn_ring0_1 << 1) + 1 + 8 * i;
-               sprintf(ring->name, "jpeg_dec_%d", i);
+               snprintf(ring->name, sizeof(ring->name), "jpeg_dec_%d", i);
                r = amdgpu_ring_init(adev, ring, 512, &adev->jpeg.inst[i].irq,
                                     0, AMDGPU_RING_PRIO_DEFAULT, NULL);
                if (r)