drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1438:58: warning: '%s' directive output may be truncated writing up to 1 bytes into a region of size between 0 and 29

From: kernel test robot
Date: Wed Oct 18 2023 - 22:13:49 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: dd72f9c7e512da377074d47d990564959b772643
commit: cc42e76e7de5190a7da5dac9d7b2bbb458e050bf drm/amd: Load MES microcode during early_init
date: 9 months ago
config: x86_64-randconfig-r006-20230904 (https://download.01.org/0day-ci/archive/20231019/202310191030.lSSsOQCJ-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/20231019/202310191030.lSSsOQCJ-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/202310191030.lSSsOQCJ-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c: In function 'amdgpu_mes_ctx_alloc_meta_data':
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1099:13: warning: variable 'r' set but not used [-Wunused-but-set-variable]
1099 | int r;
| ^
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c: In function 'amdgpu_mes_init_microcode':
>> drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1438:58: warning: '%s' directive output may be truncated writing up to 1 bytes into a region of size between 0 and 29 [-Wformat-truncation=]
1438 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes%s.bin",
| ^~
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1438:9: note: 'snprintf' output between 16 and 46 bytes into a destination of size 40
1438 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes%s.bin",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1439 | ucode_prefix,
| ~~~~~~~~~~~~~
1440 | pipe == AMDGPU_MES_SCHED_PIPE ? "" : "1");
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +1438 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c

1428
1429 int amdgpu_mes_init_microcode(struct amdgpu_device *adev, int pipe)
1430 {
1431 const struct mes_firmware_header_v1_0 *mes_hdr;
1432 struct amdgpu_firmware_info *info;
1433 char ucode_prefix[30];
1434 char fw_name[40];
1435 int r;
1436
1437 amdgpu_ucode_ip_version_decode(adev, GC_HWIP, ucode_prefix, sizeof(ucode_prefix));
> 1438 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes%s.bin",

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