Skip to contentSkip to conversation

drivers/net/ethernet/engleder/tsnep_main.c:884:55: warning: 'sprintf' may write a terminating nul past the end of the destination

DISCUSSION kernel test robot 1 participant 1 message Oct 18, 2023

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   06dc10eae55b5ceabfef287a7e5f16ceea204aa0
commit: 58eaa8abe43a0c20e4b899d51f666393e95e4833 tsnep: Move interrupt from device to queue
date:   1 year, 1 month ago
config: x86_64-randconfig-071-20230917 (https://download.01.org/0day-ci/archive/20231018/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231018/[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/net/ethernet/engleder/tsnep_main.c: In function 'tsnep_request_irq':

>> drivers/net/ethernet/engleder/tsnep_main.c:884:55: warning: 'sprintf' may write a terminating nul past the end of the destination [-Wformat-overflow=]
     884 |                         sprintf(queue->name, "%s-rx-%d", name,
         |                                                       ^
   drivers/net/ethernet/engleder/tsnep_main.c:884:25: note: 'sprintf' output between 6 and 36 bytes into a destination of size 25
     884 |                         sprintf(queue->name, "%s-rx-%d", name,
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     885 |                                 queue->rx->queue_index);
         |                                 ~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/engleder/tsnep_main.c:881:55: warning: 'sprintf' may write a terminating nul past the end of the destination [-Wformat-overflow=]
     881 |                         sprintf(queue->name, "%s-tx-%d", name,
         |                                                       ^
   drivers/net/ethernet/engleder/tsnep_main.c:881:25: note: 'sprintf' output between 6 and 36 bytes into a destination of size 25
     881 |                         sprintf(queue->name, "%s-tx-%d", name,
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     882 |                                 queue->tx->queue_index);
         |                                 ~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/net/ethernet/engleder/tsnep_main.c:878:49: warning: '-txrx-' directive writing 6 bytes into a region of size between 5 and 25 [-Wformat-overflow=]
     878 |                         sprintf(queue->name, "%s-txrx-%d", name,
         |                                                 ^~~~~~
   drivers/net/ethernet/engleder/tsnep_main.c:878:25: note: 'sprintf' output between 8 and 38 bytes into a destination of size 25
     878 |                         sprintf(queue->name, "%s-txrx-%d", name,
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     879 |                                 queue->rx->queue_index);
         |                                 ~~~~~~~~~~~~~~~~~~~~~~~

vim +/sprintf +884 drivers/net/ethernet/engleder/tsnep_main.c

864
865 static int tsnep_request_irq(struct tsnep_queue *queue, bool first)
866 {
867 const char *name = netdev_name(queue->adapter->netdev);
868 irq_handler_t handler;
869 void *dev;
870 int retval;
871
872 if (first) {
873 sprintf(queue->name, "%s-mac", name);
874 handler = tsnep_irq;
875 dev = queue->adapter;
876 } else {
877 if (queue->tx && queue->rx)

 > 878				sprintf(queue->name, "%s-txrx-%d", name,
   879					queue->rx->queue_index);
   880			else if (queue->tx)
   881				sprintf(queue->name, "%s-tx-%d", name,
   882					queue->tx->queue_index);
   883			else
 > 884				sprintf(queue->name, "%s-rx-%d", name,

885 queue->rx->queue_index);
886 handler = tsnep_irq_txrx;
887 dev = queue;
888 }
889
890 retval = request_irq(queue->irq, handler, 0, queue->name, dev);
891 if (retval) {
892 /* if name is empty, then interrupt won't be freed */
893 memset(queue->name, 0, sizeof(queue->name));
894 }
895
896 return retval;
897 }
898

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