drivers/scsi/mpt3sas/mpt3sas_base.c:2951:54: warning: '%d' directive output may be truncated writing between 1 and 3 bytes into a region of size between 1 and 26

From: kernel test robot
Date: Tue Jan 16 2024 - 17:19:09 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 052d534373b7ed33712a63d5e17b2b6cdbce84fd
commit: cdf8a76fda4ae3b53c5a09e5a8c79e27b7b65d68 ubsan: move cc-option tests into Kconfig
date: 3 years, 1 month ago
config: x86_64-randconfig-002-20240105 (https://download.01.org/0day-ci/archive/20240117/202401170432.bbjOvVyf-lkp@xxxxxxxxx/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240117/202401170432.bbjOvVyf-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/202401170432.bbjOvVyf-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

drivers/scsi/mpt3sas/mpt3sas_base.c: In function '_base_request_irq':
>> drivers/scsi/mpt3sas/mpt3sas_base.c:2951:54: warning: '%d' directive output may be truncated writing between 1 and 3 bytes into a region of size between 1 and 26 [-Wformat-truncation=]
2951 | snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d-msix%d",
| ^~
drivers/scsi/mpt3sas/mpt3sas_base.c:2951:44: note: directive argument in the range [0, 255]
2951 | snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d-msix%d",
| ^~~~~~~~~~~~~
drivers/scsi/mpt3sas/mpt3sas_base.c:2951:3: note: 'snprintf' output between 8 and 35 bytes into a destination of size 32
2951 | snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d-msix%d",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2952 | ioc->driver_name, ioc->id, index);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/mpt3sas/mpt3sas_base.c: In function 'mpt3sas_base_start_watchdog':
drivers/scsi/mpt3sas/mpt3sas_base.c:751:50: warning: '%s' directive output may be truncated writing up to 23 bytes into a region of size 15 [-Wformat-truncation=]
751 | sizeof(ioc->fault_reset_work_q_name), "poll_%s%d_status",
| ^~
drivers/scsi/mpt3sas/mpt3sas_base.c:751:44: note: directive argument in the range [0, 255]
751 | sizeof(ioc->fault_reset_work_q_name), "poll_%s%d_status",
| ^~~~~~~~~~~~~~~~~~
drivers/scsi/mpt3sas/mpt3sas_base.c:750:2: note: 'snprintf' output between 14 and 39 bytes into a destination of size 20
750 | snprintf(ioc->fault_reset_work_q_name,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
751 | sizeof(ioc->fault_reset_work_q_name), "poll_%s%d_status",
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
752 | ioc->driver_name, ioc->id);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +2951 drivers/scsi/mpt3sas/mpt3sas_base.c

f92363d12359498 Sreekanth Reddy 2012-11-30 2925
f92363d12359498 Sreekanth Reddy 2012-11-30 2926 /**
f92363d12359498 Sreekanth Reddy 2012-11-30 2927 * _base_request_irq - request irq
f92363d12359498 Sreekanth Reddy 2012-11-30 2928 * @ioc: per adapter object
f92363d12359498 Sreekanth Reddy 2012-11-30 2929 * @index: msix index into vector table
f92363d12359498 Sreekanth Reddy 2012-11-30 2930 *
f92363d12359498 Sreekanth Reddy 2012-11-30 2931 * Inserting respective reply_queue into the list.
f92363d12359498 Sreekanth Reddy 2012-11-30 2932 */
f92363d12359498 Sreekanth Reddy 2012-11-30 2933 static int
1d55abc0e98a0bf Hannes Reinecke 2017-02-22 2934 _base_request_irq(struct MPT3SAS_ADAPTER *ioc, u8 index)
f92363d12359498 Sreekanth Reddy 2012-11-30 2935 {
1d55abc0e98a0bf Hannes Reinecke 2017-02-22 2936 struct pci_dev *pdev = ioc->pdev;
f92363d12359498 Sreekanth Reddy 2012-11-30 2937 struct adapter_reply_queue *reply_q;
f92363d12359498 Sreekanth Reddy 2012-11-30 2938 int r;
f92363d12359498 Sreekanth Reddy 2012-11-30 2939
f92363d12359498 Sreekanth Reddy 2012-11-30 2940 reply_q = kzalloc(sizeof(struct adapter_reply_queue), GFP_KERNEL);
f92363d12359498 Sreekanth Reddy 2012-11-30 2941 if (!reply_q) {
919d8a3f3fef991 Joe Perches 2018-09-17 2942 ioc_err(ioc, "unable to allocate memory %zu!\n",
919d8a3f3fef991 Joe Perches 2018-09-17 2943 sizeof(struct adapter_reply_queue));
f92363d12359498 Sreekanth Reddy 2012-11-30 2944 return -ENOMEM;
f92363d12359498 Sreekanth Reddy 2012-11-30 2945 }
f92363d12359498 Sreekanth Reddy 2012-11-30 2946 reply_q->ioc = ioc;
f92363d12359498 Sreekanth Reddy 2012-11-30 2947 reply_q->msix_index = index;
14b3114d940cdc4 Sreekanth Reddy 2015-01-12 2948
f92363d12359498 Sreekanth Reddy 2012-11-30 2949 atomic_set(&reply_q->busy, 0);
f92363d12359498 Sreekanth Reddy 2012-11-30 2950 if (ioc->msix_enable)
f92363d12359498 Sreekanth Reddy 2012-11-30 @2951 snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d-msix%d",
c84b06a48c4d8ac Sreekanth Reddy 2015-11-11 2952 ioc->driver_name, ioc->id, index);
f92363d12359498 Sreekanth Reddy 2012-11-30 2953 else
f92363d12359498 Sreekanth Reddy 2012-11-30 2954 snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d",
c84b06a48c4d8ac Sreekanth Reddy 2015-11-11 2955 ioc->driver_name, ioc->id);
1d55abc0e98a0bf Hannes Reinecke 2017-02-22 2956 r = request_irq(pci_irq_vector(pdev, index), _base_interrupt,
1d55abc0e98a0bf Hannes Reinecke 2017-02-22 2957 IRQF_SHARED, reply_q->name, reply_q);
f92363d12359498 Sreekanth Reddy 2012-11-30 2958 if (r) {
fc7d510ec4c8ff8 Joe Perches 2018-09-17 2959 pr_err("%s: unable to allocate interrupt %d!\n",
1d55abc0e98a0bf Hannes Reinecke 2017-02-22 2960 reply_q->name, pci_irq_vector(pdev, index));
da3cec2515f0094 Suganath prabu Subramani 2016-02-11 2961 kfree(reply_q);
f92363d12359498 Sreekanth Reddy 2012-11-30 2962 return -EBUSY;
f92363d12359498 Sreekanth Reddy 2012-11-30 2963 }
f92363d12359498 Sreekanth Reddy 2012-11-30 2964
f92363d12359498 Sreekanth Reddy 2012-11-30 2965 INIT_LIST_HEAD(&reply_q->list);
f92363d12359498 Sreekanth Reddy 2012-11-30 2966 list_add_tail(&reply_q->list, &ioc->reply_queue_list);
f92363d12359498 Sreekanth Reddy 2012-11-30 2967 return 0;
f92363d12359498 Sreekanth Reddy 2012-11-30 2968 }
f92363d12359498 Sreekanth Reddy 2012-11-30 2969

:::::: The code at line 2951 was first introduced by commit
:::::: f92363d12359498f9a9960511de1a550f0ec41c2 [SCSI] mpt3sas: add new driver supporting 12GB SAS

:::::: TO: Sreekanth Reddy <Sreekanth.Reddy@xxxxxxx>
:::::: CC: James Bottomley <JBottomley@xxxxxxxxxxxxx>

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