drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1443:66: warning: '%s' directive output may be truncated writing 1 byte into a region of size between 0 and 29
From: kernel test robot
Date: Fri Oct 20 2023 - 15:36:34 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: c3200081020d63f6c6bfd8a6db2ae8a5b99b348a
commit: 97998b893c3000b27a780a4982e16cfc8f4ea555 drm/amd/amdgpu: introduce gc_*_mes_2.bin v2
date: 6 months ago
config: x86_64-randconfig-x051-20230809 (https://download.01.org/0day-ci/archive/20231021/202310210328.KaJWGR5u-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/202310210328.KaJWGR5u-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/202310210328.KaJWGR5u-lkp@xxxxxxxxx/
All warnings (new ones prefixed by >>):
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c: In function 'amdgpu_mes_init_microcode':
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1448:66: warning: '%s' directive output may be truncated writing up to 1 bytes into a region of size between 0 and 29 [-Wformat-truncation=]
1448 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes%s.bin",
| ^~
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1448:17: note: 'snprintf' output between 16 and 46 bytes into a destination of size 40
1448 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes%s.bin",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1449 | ucode_prefix,
| ~~~~~~~~~~~~~
1450 | pipe == AMDGPU_MES_SCHED_PIPE ? "" : "1");
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1443:66: warning: '%s' directive output may be truncated writing 1 byte into a region of size between 0 and 29 [-Wformat-truncation=]
1443 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes%s.bin",
| ^~
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1443:17: note: 'snprintf' output between 17 and 46 bytes into a destination of size 40
1443 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes%s.bin",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1444 | ucode_prefix,
| ~~~~~~~~~~~~~
1445 | pipe == AMDGPU_MES_SCHED_PIPE ? "_2" : "1");
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1443:66: warning: '%s' directive output may be truncated writing 2 bytes into a region of size between 0 and 29 [-Wformat-truncation=]
1443 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes%s.bin",
| ^~
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1443:17: note: 'snprintf' output between 18 and 47 bytes into a destination of size 40
1443 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes%s.bin",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1444 | ucode_prefix,
| ~~~~~~~~~~~~~
1445 | pipe == AMDGPU_MES_SCHED_PIPE ? "_2" : "1");
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1455:62: warning: '_mes.bin' directive output may be truncated writing 8 bytes into a region of size between 4 and 33 [-Wformat-truncation=]
1455 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes.bin",
| ^~~~~~~~
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1455:17: note: 'snprintf' output between 16 and 45 bytes into a destination of size 40
1455 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes.bin",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1456 | ucode_prefix);
| ~~~~~~~~~~~~~
vim +1443 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
1430
1431 int amdgpu_mes_init_microcode(struct amdgpu_device *adev, int pipe)
1432 {
1433 const struct mes_firmware_header_v1_0 *mes_hdr;
1434 struct amdgpu_firmware_info *info;
1435 char ucode_prefix[30];
1436 char fw_name[40];
1437 bool need_retry = false;
1438 int r;
1439
1440 amdgpu_ucode_ip_version_decode(adev, GC_HWIP, ucode_prefix,
1441 sizeof(ucode_prefix));
1442 if (adev->ip_versions[GC_HWIP][0] >= IP_VERSION(11, 0, 0)) {
> 1443 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes%s.bin",
1444 ucode_prefix,
1445 pipe == AMDGPU_MES_SCHED_PIPE ? "_2" : "1");
1446 need_retry = true;
1447 } else {
> 1448 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes%s.bin",
1449 ucode_prefix,
1450 pipe == AMDGPU_MES_SCHED_PIPE ? "" : "1");
1451 }
1452
1453 r = amdgpu_ucode_request(adev, &adev->mes.fw[pipe], fw_name);
1454 if (r && need_retry && pipe == AMDGPU_MES_SCHED_PIPE) {
> 1455 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes.bin",
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki