drivers/scsi/mpi3mr/mpi3mr_fw.c:360:58: warning: '%d' directive output may be truncated writing between 1 and 3 bytes into a region of size between 1 and 32

From: kernel test robot
Date: Mon Dec 02 2024 - 23:50:51 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: cdd30ebb1b9f36159d66f088b61aee264e649d7a
commit: 824a156633dfdb0e17979a0d0bb2c757d1bb949c scsi: mpi3mr: Base driver code
date: 3 years, 6 months ago
config: x86_64-randconfig-015-20240106 (https://download.01.org/0day-ci/archive/20241203/202412031228.7IB2UW85-lkp@xxxxxxxxx/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241203/202412031228.7IB2UW85-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/202412031228.7IB2UW85-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

drivers/scsi/mpi3mr/mpi3mr_fw.c: In function 'mpi3mr_setup_isr':
>> drivers/scsi/mpi3mr/mpi3mr_fw.c:360:58: warning: '%d' directive output may be truncated writing between 1 and 3 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
360 | snprintf(intr_info->name, MPI3MR_NAME_LENGTH, "%s%d-msix%d",
| ^~
drivers/scsi/mpi3mr/mpi3mr_fw.c:360:55: note: directive argument in the range [0, 255]
360 | snprintf(intr_info->name, MPI3MR_NAME_LENGTH, "%s%d-msix%d",
| ^~~~~~~~~~~~~
drivers/scsi/mpi3mr/mpi3mr_fw.c:360:55: note: directive argument in the range [0, 65535]
drivers/scsi/mpi3mr/mpi3mr_fw.c:360:9: note: 'snprintf' output between 8 and 45 bytes into a destination of size 32
360 | snprintf(intr_info->name, MPI3MR_NAME_LENGTH, "%s%d-msix%d",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
361 | mrioc->driver_name, mrioc->id, index);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
drivers/scsi/mpi3mr/mpi3mr_os.c: In function 'mpi3mr_probe':
>> drivers/scsi/mpi3mr/mpi3mr_os.c:210:33: warning: '%d' directive writing between 1 and 3 bytes into a region of size between 1 and 32 [-Wformat-overflow=]
210 | sprintf(mrioc->name, "%s%d", mrioc->driver_name, mrioc->id);
| ^~
drivers/scsi/mpi3mr/mpi3mr_os.c:210:30: note: directive argument in the range [0, 255]
210 | sprintf(mrioc->name, "%s%d", mrioc->driver_name, mrioc->id);
| ^~~~~~
drivers/scsi/mpi3mr/mpi3mr_os.c:210:9: note: 'sprintf' output between 2 and 35 bytes into a destination of size 32
210 | sprintf(mrioc->name, "%s%d", mrioc->driver_name, mrioc->id);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +360 drivers/scsi/mpi3mr/mpi3mr_fw.c

340
341 /**
342 * mpi3mr_request_irq - Request IRQ and register ISR
343 * @mrioc: Adapter instance reference
344 * @index: IRQ vector index
345 *
346 * Request threaded ISR with primary ISR and secondary
347 *
348 * Return: 0 on success and non zero on failures.
349 */
350 static inline int mpi3mr_request_irq(struct mpi3mr_ioc *mrioc, u16 index)
351 {
352 struct pci_dev *pdev = mrioc->pdev;
353 struct mpi3mr_intr_info *intr_info = mrioc->intr_info + index;
354 int retval = 0;
355
356 intr_info->mrioc = mrioc;
357 intr_info->msix_index = index;
358 intr_info->op_reply_q = NULL;
359
> 360 snprintf(intr_info->name, MPI3MR_NAME_LENGTH, "%s%d-msix%d",
361 mrioc->driver_name, mrioc->id, index);
362
363 retval = request_threaded_irq(pci_irq_vector(pdev, index), mpi3mr_isr,
364 mpi3mr_isr_poll, IRQF_SHARED, intr_info->name, intr_info);
365 if (retval) {
366 ioc_err(mrioc, "%s: Unable to allocate interrupt %d!\n",
367 intr_info->name, pci_irq_vector(pdev, index));
368 return retval;
369 }
370
371 return retval;
372 }
373

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