drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:326:40: warning: '%d' directive writing between 1 and 10 bytes into a region of size between 0 and 8

From: kernel test robot
Date: Fri Oct 20 2023 - 19:41:45 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: f74e3ea3ba9cdef948999c29c1c9793ea26787b4
commit: def799c6596d078112095c24c25e162cb5102d90 drm/amdgpu: add multi-xcc support to amdgpu_gfx interfaces (v4)
date: 6 months ago
config: x86_64-randconfig-x051-20230809 (https://download.01.org/0day-ci/archive/20231021/202310210731.mugeov4Z-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231021/202310210731.mugeov4Z-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310210731.mugeov4Z-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c: In function 'amdgpu_gfx_mqd_sw_fini':
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:451:16: warning: variable 'j' set but not used [-Wunused-but-set-variable]
451 | int i, j;
| ^
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c: In function 'amdgpu_gfx_disable_kcq':
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:486:13: warning: variable 'j' set but not used [-Wunused-but-set-variable]
486 | int j;
| ^
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c: In function 'amdgpu_gfx_enable_kcq':
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:529:19: warning: variable 'j' set but not used [-Wunused-but-set-variable]
529 | int r, i, j;
| ^
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c: In function 'amdgpu_gfx_kiq_init_ring':
>> drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:326:40: warning: '%d' directive writing between 1 and 10 bytes into a region of size between 0 and 8 [-Wformat-overflow=]
326 | sprintf(ring->name, "kiq_%d.%d.%d.%d", xcc_id, ring->me, ring->pipe, ring->queue);
| ^~
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:326:29: note: directive argument in the range [0, 2147483647]
326 | sprintf(ring->name, "kiq_%d.%d.%d.%d", xcc_id, ring->me, ring->pipe, ring->queue);
| ^~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:326:9: note: 'sprintf' output between 12 and 41 bytes into a destination of size 16
326 | sprintf(ring->name, "kiq_%d.%d.%d.%d", xcc_id, ring->me, ring->pipe, ring->queue);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +326 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c

303
304 int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev,
305 struct amdgpu_ring *ring,
306 struct amdgpu_irq_src *irq, int xcc_id)
307 {
308 struct amdgpu_kiq *kiq = &adev->gfx.kiq[xcc_id];
309 int r = 0;
310
311 spin_lock_init(&kiq->ring_lock);
312
313 ring->adev = NULL;
314 ring->ring_obj = NULL;
315 ring->use_doorbell = true;
316 ring->doorbell_index = adev->doorbell_index.kiq;
317 ring->xcc_id = xcc_id;
318 ring->vm_hub = AMDGPU_GFXHUB_0;
319
320 r = amdgpu_gfx_kiq_acquire(adev, ring, xcc_id);
321 if (r)
322 return r;
323
324 ring->eop_gpu_addr = kiq->eop_gpu_addr;
325 ring->no_scheduler = true;
> 326 sprintf(ring->name, "kiq_%d.%d.%d.%d", xcc_id, ring->me, ring->pipe, ring->queue);
327 r = amdgpu_ring_init(adev, ring, 1024, irq, AMDGPU_CP_KIQ_IRQ_DRIVER0,
328 AMDGPU_RING_PRIO_DEFAULT, NULL);
329 if (r)
330 dev_warn(adev->dev, "(%d) failed to init kiq ring\n", r);
331
332 return r;
333 }
334

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki