drivers/scsi/mpt3sas/mpt3sas_base.c:3135:49: warning: '-mq-poll' directive output may be truncated writing 8 bytes into a region of size between 6 and 31

From: kernel test robot
Date: Fri Jan 12 2024 - 10:18:07 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 70d201a40823acba23899342d62bc2644051ad2e
commit: 432bc7caef4eaacc1101ee2569bb870bdfeed7ce scsi: mpt3sas: Add io_uring iopoll support
date: 2 years, 5 months ago
config: x86_64-randconfig-002-20240105 (https://download.01.org/0day-ci/archive/20240112/202401122336.ZuzNmzYi-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/20240112/202401122336.ZuzNmzYi-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/202401122336.ZuzNmzYi-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:3144: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=]
3144 | snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d-msix%d",
| ^~
drivers/scsi/mpt3sas/mpt3sas_base.c:3144:44: note: directive argument in the range [0, 255]
3144 | snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d-msix%d",
| ^~~~~~~~~~~~~
drivers/scsi/mpt3sas/mpt3sas_base.c:3144:3: note: 'snprintf' output between 8 and 35 bytes into a destination of size 32
3144 | snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d-msix%d",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3145 | ioc->driver_name, ioc->id, index);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/scsi/mpt3sas/mpt3sas_base.c:3135:49: warning: '-mq-poll' directive output may be truncated writing 8 bytes into a region of size between 6 and 31 [-Wformat-truncation=]
3135 | snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d-mq-poll%d",
| ^~~~~~~~
drivers/scsi/mpt3sas/mpt3sas_base.c:3135:44: note: directive argument in the range [-255, 255]
3135 | snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d-mq-poll%d",
| ^~~~~~~~~~~~~~~~
drivers/scsi/mpt3sas/mpt3sas_base.c:3135:3: note: 'snprintf' output between 11 and 39 bytes into a destination of size 32
3135 | snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d-mq-poll%d",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3136 | ioc->driver_name, ioc->id, qid);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/mpt3sas/mpt3sas_base.c: In function 'mpt3sas_base_start_watchdog':
drivers/scsi/mpt3sas/mpt3sas_base.c:831:50: warning: '%s' directive output may be truncated writing up to 23 bytes into a region of size 15 [-Wformat-truncation=]
831 | sizeof(ioc->fault_reset_work_q_name), "poll_%s%d_status",
| ^~
drivers/scsi/mpt3sas/mpt3sas_base.c:831:44: note: directive argument in the range [0, 255]
831 | sizeof(ioc->fault_reset_work_q_name), "poll_%s%d_status",
| ^~~~~~~~~~~~~~~~~~
drivers/scsi/mpt3sas/mpt3sas_base.c:830:2: note: 'snprintf' output between 14 and 39 bytes into a destination of size 20
830 | snprintf(ioc->fault_reset_work_q_name,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
831 | sizeof(ioc->fault_reset_work_q_name), "poll_%s%d_status",
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
832 | ioc->driver_name, ioc->id);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~


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

3107
3108 /**
3109 * _base_request_irq - request irq
3110 * @ioc: per adapter object
3111 * @index: msix index into vector table
3112 *
3113 * Inserting respective reply_queue into the list.
3114 */
3115 static int
3116 _base_request_irq(struct MPT3SAS_ADAPTER *ioc, u8 index)
3117 {
3118 struct pci_dev *pdev = ioc->pdev;
3119 struct adapter_reply_queue *reply_q;
3120 int r, qid;
3121
3122 reply_q = kzalloc(sizeof(struct adapter_reply_queue), GFP_KERNEL);
3123 if (!reply_q) {
3124 ioc_err(ioc, "unable to allocate memory %zu!\n",
3125 sizeof(struct adapter_reply_queue));
3126 return -ENOMEM;
3127 }
3128 reply_q->ioc = ioc;
3129 reply_q->msix_index = index;
3130
3131 atomic_set(&reply_q->busy, 0);
3132
3133 if (index >= ioc->iopoll_q_start_index) {
3134 qid = index - ioc->iopoll_q_start_index;
> 3135 snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d-mq-poll%d",
3136 ioc->driver_name, ioc->id, qid);
3137 reply_q->is_iouring_poll_q = 1;
3138 ioc->io_uring_poll_queues[qid].reply_q = reply_q;
3139 goto out;
3140 }
3141
3142
3143 if (ioc->msix_enable)
3144 snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d-msix%d",
3145 ioc->driver_name, ioc->id, index);
3146 else
3147 snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d",
3148 ioc->driver_name, ioc->id);
3149 r = request_irq(pci_irq_vector(pdev, index), _base_interrupt,
3150 IRQF_SHARED, reply_q->name, reply_q);
3151 if (r) {
3152 pr_err("%s: unable to allocate interrupt %d!\n",
3153 reply_q->name, pci_irq_vector(pdev, index));
3154 kfree(reply_q);
3155 return -EBUSY;
3156 }
3157 out:
3158 INIT_LIST_HEAD(&reply_q->list);
3159 list_add_tail(&reply_q->list, &ioc->reply_queue_list);
3160 return 0;
3161 }
3162

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