arch/powerpc/platforms/pseries/lpar.c:2032:36: error: '%ld' directive writing between 1 and 20 bytes into a region of size 12

kernel test robot
2023-10-18T23:30:44Z

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: dd72f9c7e512da377074d47d990564959b772643
commit: 33e67710beda78aed38a2fe10be6088d4aeb1c53 cpumask: switch for_each_cpu{,_not} to use for_each_bit()
date: 1 year, 1 month ago
config: powerpc64-randconfig-r003-20220418 (https://download.01.org/0day-ci/archive/20231019/202310190736.sgDpsRRj-lkp@intel.com/config)
compiler: powerpc64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231019/202310190736.sgDpsRRj-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310190736.sgDpsRRj-lkp@intel.com/

All errors (new ones prefixed by >>):

arch/powerpc/platforms/pseries/lpar.c: In function '__machine_initcall_pseries_vpa_debugfs_init':
>> arch/powerpc/platforms/pseries/lpar.c:2032:36: error: '%ld' directive writing between 1 and 20 bytes into a region of size 12 [-Werror=format-overflow=]
2032 | sprintf(name, "cpu-%ld", i);
| ^~~
In function 'vpa_debugfs_init',
inlined from '__machine_initcall_pseries_vpa_debugfs_init' at arch/powerpc/platforms/pseries/lpar.c:2038:1:
arch/powerpc/platforms/pseries/lpar.c:2032:31: note: directive argument in the range [-9223372036854775808, 4294967294]
2032 | sprintf(name, "cpu-%ld", i);
| ^~~~~~~~~
arch/powerpc/platforms/pseries/lpar.c:2032:17: note: 'sprintf' output between 6 and 25 bytes into a destination of size 16
2032 | sprintf(name, "cpu-%ld", i);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
--
arch/powerpc/sysdev/xive/common.c: In function 'xive_core_debug_init':
>> arch/powerpc/sysdev/xive/common.c:1845:50: error: '%ld' directive output may be truncated writing between 1 and 20 bytes into a region of size 13 [-Werror=format-truncation=]
1845 | snprintf(name, sizeof(name), "cpu%ld", cpu);
| ^~~
In function 'xive_core_debugfs_create',
inlined from 'xive_core_debug_init' at arch/powerpc/sysdev/xive/common.c:1861:3:
arch/powerpc/sysdev/xive/common.c:1845:46: note: directive argument in the range [-9223372036854775808, 4294967294]
1845 | snprintf(name, sizeof(name), "cpu%ld", cpu);
| ^~~~~~~~
arch/powerpc/sysdev/xive/common.c:1845:17: note: 'snprintf' output between 5 and 24 bytes into a destination of size 16
1845 | snprintf(name, sizeof(name), "cpu%ld", cpu);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

vim +2032 arch/powerpc/platforms/pseries/lpar.c

c6c26fb55e8e4b Aravinda Prasad 2018-10-16 2018
c6c26fb55e8e4b Aravinda Prasad 2018-10-16 2019 static int __init vpa_debugfs_init(void)
c6c26fb55e8e4b Aravinda Prasad 2018-10-16 2020 {
c6c26fb55e8e4b Aravinda Prasad 2018-10-16 2021 char name[16];
c6c26fb55e8e4b Aravinda Prasad 2018-10-16 2022 long i;
11dd34f3eae5a4 YueHaibing 2019-02-18 2023 struct dentry *vpa_dir;
c6c26fb55e8e4b Aravinda Prasad 2018-10-16 2024
c6c26fb55e8e4b Aravinda Prasad 2018-10-16 2025 if (!firmware_has_feature(FW_FEATURE_SPLPAR))
c6c26fb55e8e4b Aravinda Prasad 2018-10-16 2026 return 0;
c6c26fb55e8e4b Aravinda Prasad 2018-10-16 2027
dbf77fed8b302e Aneesh Kumar K.V 2021-08-12 2028 vpa_dir = debugfs_create_dir("vpa", arch_debugfs_dir);
c6c26fb55e8e4b Aravinda Prasad 2018-10-16 2029
c6c26fb55e8e4b Aravinda Prasad 2018-10-16 2030 /* set up the per-cpu vpa file*/
c6c26fb55e8e4b Aravinda Prasad 2018-10-16 2031 for_each_possible_cpu(i) {
c6c26fb55e8e4b Aravinda Prasad 2018-10-16 @2032 sprintf(name, "cpu-%ld", i);

:::::: The code at line 2032 was first introduced by commit
:::::: c6c26fb55e8e4b3fc376be5611685990a17de27a powerpc/pseries: Export raw per-CPU VPA data via debugfs

:::::: TO: Aravinda Prasad <aravinda@linux.vnet.ibm.com>
:::::: CC: Michael Ellerman <mpe@ellerman.id.au>

--
0-DAY CI Kernel Test Service