Skip to contentSkip to conversation

drivers/infiniband/hw/mlx5/mr.c:840:31: warning: 'sprintf' may write a terminating nul past the end of the destination

PATCH kernel test robot 1 participant 1 message Aug 21, 2025

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   7fa4d8dc380fbd81a9d702a855c50690c9c6442c
commit: de88e74889a30bd9ff4047726021cde857348b4b [3631/3950] s390/bitops: Slightly optimize ffs() and fls64()
config: s390-allyesconfig (https://download.01.org/0day-ci/archive/20250821/[email protected]/config)
compiler: s390-linux-gcc (GCC) 15.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250821/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/infiniband/hw/mlx5/mr.c: In function 'mlx5r_cache_create_ent_locked':

>> drivers/infiniband/hw/mlx5/mr.c:840:31: warning: 'sprintf' may write a terminating nul past the end of the destination [-Wformat-overflow=]
     840 |         sprintf(ent->name, "%d", order);
         |                               ^
   In function 'mlx5_mkey_cache_debugfs_add_ent',
       inlined from 'mlx5r_cache_create_ent_locked' at drivers/infiniband/hw/mlx5/mr.c:930:3:
   drivers/infiniband/hw/mlx5/mr.c:840:9: note: 'sprintf' output between 2 and 5 bytes into a destination of size 4
     840 |         sprintf(ent->name, "%d", order);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/sprintf +840 drivers/infiniband/hw/mlx5/mr.c

12cc1a02734133 Leon Romanovsky    2017-05-30  827  
73d09b2fe8336f Michael Guralnik   2023-01-26  828  static void mlx5_mkey_cache_debugfs_add_ent(struct mlx5_ib_dev *dev,
73d09b2fe8336f Michael Guralnik   2023-01-26  829  					    struct mlx5_cache_ent *ent)
e126ba97dba9ed Eli Cohen          2013-07-07  830  {
73d09b2fe8336f Michael Guralnik   2023-01-26  831  	int order = order_base_2(ent->rb_key.ndescs);
73eb8f03f0ecfc Greg Kroah-Hartman 2019-01-22  832  	struct dentry *dir;
e126ba97dba9ed Eli Cohen          2013-07-07  833  
828cf5936bea24 Leon Romanovsky    2023-02-02  834  	if (!mlx5_debugfs_root || dev->is_rep)
828cf5936bea24 Leon Romanovsky    2023-02-02  835  		return;
828cf5936bea24 Leon Romanovsky    2023-02-02  836  
73d09b2fe8336f Michael Guralnik   2023-01-26  837  	if (ent->rb_key.access_mode == MLX5_MKC_ACCESS_MODE_KSM)
73d09b2fe8336f Michael Guralnik   2023-01-26  838  		order = MLX5_IMR_KSM_CACHE_ENTRY + 2;
e126ba97dba9ed Eli Cohen          2013-07-07  839  
73d09b2fe8336f Michael Guralnik   2023-01-26 @840  	sprintf(ent->name, "%d", order);
73d09b2fe8336f Michael Guralnik   2023-01-26  841  	dir = debugfs_create_dir(ent->name, dev->cache.fs_root);
73eb8f03f0ecfc Greg Kroah-Hartman 2019-01-22  842  	debugfs_create_file("size", 0600, dir, ent, &size_fops);
73eb8f03f0ecfc Greg Kroah-Hartman 2019-01-22  843  	debugfs_create_file("limit", 0600, dir, ent, &limit_fops);
57e7071683ef61 Shay Drory         2023-09-21  844  	debugfs_create_ulong("cur", 0400, dir, &ent->mkeys_queue.ci);
73eb8f03f0ecfc Greg Kroah-Hartman 2019-01-22  845  	debugfs_create_u32("miss", 0600, dir, &ent->miss);
e126ba97dba9ed Eli Cohen          2013-07-07  846  }

73d09b2fe8336f Michael Guralnik 2023-01-26 847

:::::: The code at line 840 was first introduced by commit
:::::: 73d09b2fe8336f5f37935e46418666ddbcd3c343 RDMA/mlx5: Introduce mlx5r_cache_rb_key

:::::: TO: Michael Guralnik <[email protected]> :::::: CC: Jason Gunthorpe <[email protected]>

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