lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 4 Nov 2022 08:46:48 +0800
From:   kernel test robot <lkp@...el.com>
To:     Zhang Changzhong <zhangchangzhong@...wei.com>,
        Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Jeff Garzik <jgarzik@...ox.com>,
        Finn Thain <fthain@...ux-m68k.org>
Cc:     oe-kbuild-all@...ts.linux.dev, netdev@...r.kernel.org,
        Zhang Changzhong <zhangchangzhong@...wei.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH net] net/sonic: use dma_mapping_error() for error check

Hi Zhang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Zhang-Changzhong/net-sonic-use-dma_mapping_error-for-error-check/20221031-204340
patch link:    https://lore.kernel.org/r/1667221322-8317-1-git-send-email-zhangchangzhong%40huawei.com
patch subject: [PATCH net] net/sonic: use dma_mapping_error() for error check
config: m68k-allyesconfig
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/837273d17ba29bbc661c5c82432e83ce4198200a
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Zhang-Changzhong/net-sonic-use-dma_mapping_error-for-error-check/20221031-204340
        git checkout 837273d17ba29bbc661c5c82432e83ce4198200a
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/net/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>

All warnings (new ones prefixed by >>):

   In file included from drivers/net/ethernet/natsemi/macsonic.c:533:
   drivers/net/ethernet/natsemi/sonic.c: In function 'sonic_send_packet':
>> drivers/net/ethernet/natsemi/sonic.c:295:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     295 |         if (dma_mapping_error(lp->device, laddr))
         |         ^~
   drivers/net/ethernet/natsemi/sonic.c:297:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
     297 |                 dev_kfree_skb_any(skb);
         |                 ^~~~~~~~~~~~~~~~~
   drivers/net/ethernet/natsemi/sonic.c:279:23: warning: unused variable 'flags' [-Wunused-variable]
     279 |         unsigned long flags;
         |                       ^~~~~
   drivers/net/ethernet/natsemi/sonic.c:278:13: warning: unused variable 'entry' [-Wunused-variable]
     278 |         int entry;
         |             ^~~~~
   In file included from include/linux/kref.h:16,
                    from include/linux/mm_types.h:8,
                    from include/linux/buildid.h:5,
                    from include/linux/module.h:14,
                    from drivers/net/ethernet/natsemi/macsonic.c:36:
   drivers/net/ethernet/natsemi/sonic.c: At top level:
   include/linux/spinlock.h:379:1: error: expected identifier or '(' before 'do'
     379 | do {                                                            \
         | ^~
   drivers/net/ethernet/natsemi/sonic.c:301:9: note: in expansion of macro 'spin_lock_irqsave'
     301 |         spin_lock_irqsave(&lp->lock, flags);
         |         ^~~~~~~~~~~~~~~~~
   include/linux/spinlock.h:381:3: error: expected identifier or '(' before 'while'
     381 | } while (0)
         |   ^~~~~
   drivers/net/ethernet/natsemi/sonic.c:301:9: note: in expansion of macro 'spin_lock_irqsave'
     301 |         spin_lock_irqsave(&lp->lock, flags);
         |         ^~~~~~~~~~~~~~~~~
>> drivers/net/ethernet/natsemi/sonic.c:303:9: warning: data definition has no type or storage class
     303 |         entry = (lp->eol_tx + 1) & SONIC_TDS_MASK;
         |         ^~~~~
   drivers/net/ethernet/natsemi/sonic.c:303:9: error: type defaults to 'int' in declaration of 'entry' [-Werror=implicit-int]
   drivers/net/ethernet/natsemi/sonic.c:303:18: error: 'lp' undeclared here (not in a function); did you mean 'up'?
     303 |         entry = (lp->eol_tx + 1) & SONIC_TDS_MASK;
         |                  ^~
         |                  up
   drivers/net/ethernet/natsemi/sonic.c:305:34: error: expected ')' before numeric constant
     305 |         sonic_tda_put(dev, entry, SONIC_TD_STATUS, 0);       /* clear status */
         |                                  ^
         |                                  )
   drivers/net/ethernet/natsemi/sonic.c:306:34: error: expected ')' before numeric constant
     306 |         sonic_tda_put(dev, entry, SONIC_TD_FRAG_COUNT, 1);   /* single fragment */
         |                                  ^
         |                                  )
   drivers/net/ethernet/natsemi/sonic.c:307:34: error: expected ')' before numeric constant
     307 |         sonic_tda_put(dev, entry, SONIC_TD_PKTSIZE, length); /* length of packet */
         |                                  ^
         |                                  )
   drivers/net/ethernet/natsemi/sonic.c:308:34: error: expected ')' before numeric constant
     308 |         sonic_tda_put(dev, entry, SONIC_TD_FRAG_PTR_L, laddr & 0xffff);
         |                                  ^
         |                                  )
   drivers/net/ethernet/natsemi/sonic.c:309:34: error: expected ')' before numeric constant
     309 |         sonic_tda_put(dev, entry, SONIC_TD_FRAG_PTR_H, laddr >> 16);
         |                                  ^
         |                                  )
   drivers/net/ethernet/natsemi/sonic.c:310:34: error: expected ')' before numeric constant
     310 |         sonic_tda_put(dev, entry, SONIC_TD_FRAG_SIZE, length);
         |                                  ^
         |                                  )
   drivers/net/ethernet/natsemi/sonic.c:311:34: error: expected ')' before numeric constant
     311 |         sonic_tda_put(dev, entry, SONIC_TD_LINK,
         |                                  ^
         |                                  )
   drivers/net/ethernet/natsemi/sonic.c:314:30: error: expected ')' before '->' token
     314 |         sonic_tda_put(dev, lp->eol_tx, SONIC_TD_LINK, ~SONIC_EOL &
         |                              ^~
         |                              )
   In file included from include/linux/skbuff.h:45,
                    from include/net/net_namespace.h:43,
                    from include/linux/netdevice.h:38,
                    from drivers/net/ethernet/natsemi/macsonic.c:47:
   include/net/net_debug.h:114:1: error: expected identifier or '(' before 'do'
     114 | do {                                                            \
         | ^~
   drivers/net/ethernet/natsemi/sonic.c:317:9: note: in expansion of macro 'netif_dbg'
     317 |         netif_dbg(lp, tx_queued, dev, "%s: issuing Tx command\n", __func__);
         |         ^~~~~~~~~
   include/net/net_debug.h:117:3: error: expected identifier or '(' before 'while'
     117 | } while (0)
         |   ^~~~~
   drivers/net/ethernet/natsemi/sonic.c:317:9: note: in expansion of macro 'netif_dbg'
     317 |         netif_dbg(lp, tx_queued, dev, "%s: issuing Tx command\n", __func__);
         |         ^~~~~~~~~
   In file included from arch/m68k/include/asm/io_mm.h:25,
                    from arch/m68k/include/asm/io.h:8,
                    from include/linux/io.h:13,
                    from include/linux/irq.h:20,
                    from include/asm-generic/hardirq.h:17,
                    from ./arch/m68k/include/generated/asm/hardirq.h:1,
                    from include/linux/hardirq.h:11,
                    from include/linux/interrupt.h:11,
                    from drivers/net/ethernet/natsemi/macsonic.c:40:
   arch/m68k/include/asm/raw_io.h:31:27: error: expected identifier or '(' before 'void'
      31 | #define out_be16(addr,w) (void)((*(__force volatile u16 *) (unsigned long)(addr)) = (w))
         |                           ^~~~
   arch/m68k/include/asm/raw_io.h:44:28: note: in expansion of macro 'out_be16'
      44 | #define raw_outw(val,port) out_be16((port),(val))
         |                            ^~~~~~~~
   arch/m68k/include/asm/nubus.h:13:22: note: in expansion of macro 'raw_outw'
      13 | #define nubus_writew raw_outw
         |                      ^~~~~~~~
   drivers/net/ethernet/natsemi/macsonic.c:70:31: note: in expansion of macro 'nubus_writew'
      70 | #define SONIC_WRITE(reg,val) (nubus_writew(val, dev->base_addr + (reg * 4) \
         |                               ^~~~~~~~~~~~
   drivers/net/ethernet/natsemi/sonic.c:319:9: note: in expansion of macro 'SONIC_WRITE'
     319 |         SONIC_WRITE(SONIC_CMD, SONIC_CR_TXP);
         |         ^~~~~~~~~~~
   arch/m68k/include/asm/raw_io.h:31:32: error: expected ')' before '(' token
      31 | #define out_be16(addr,w) (void)((*(__force volatile u16 *) (unsigned long)(addr)) = (w))
         |                                ^
   arch/m68k/include/asm/raw_io.h:44:28: note: in expansion of macro 'out_be16'
      44 | #define raw_outw(val,port) out_be16((port),(val))
         |                            ^~~~~~~~
   arch/m68k/include/asm/nubus.h:13:22: note: in expansion of macro 'raw_outw'
      13 | #define nubus_writew raw_outw
         |                      ^~~~~~~~
   drivers/net/ethernet/natsemi/macsonic.c:70:31: note: in expansion of macro 'nubus_writew'
      70 | #define SONIC_WRITE(reg,val) (nubus_writew(val, dev->base_addr + (reg * 4) \
         |                               ^~~~~~~~~~~~
   drivers/net/ethernet/natsemi/sonic.c:319:9: note: in expansion of macro 'SONIC_WRITE'
     319 |         SONIC_WRITE(SONIC_CMD, SONIC_CR_TXP);
         |         ^~~~~~~~~~~
   drivers/net/ethernet/natsemi/sonic.c:321:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
     321 |         lp->tx_len[entry] = length;
         |           ^~
   drivers/net/ethernet/natsemi/sonic.c:322:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
     322 |         lp->tx_laddr[entry] = laddr;
         |           ^~


vim +/if +295 drivers/net/ethernet/natsemi/sonic.c

   254	
   255	/*
   256	 * transmit packet
   257	 *
   258	 * Appends new TD during transmission thus avoiding any TX interrupts
   259	 * until we run out of TDs.
   260	 * This routine interacts closely with the ISR in that it may,
   261	 *   set tx_skb[i]
   262	 *   reset the status flags of the new TD
   263	 *   set and reset EOL flags
   264	 *   stop the tx queue
   265	 * The ISR interacts with this routine in various ways. It may,
   266	 *   reset tx_skb[i]
   267	 *   test the EOL and status flags of the TDs
   268	 *   wake the tx queue
   269	 * Concurrently with all of this, the SONIC is potentially writing to
   270	 * the status flags of the TDs.
   271	 */
   272	
   273	static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev)
   274	{
   275		struct sonic_local *lp = netdev_priv(dev);
   276		dma_addr_t laddr;
   277		int length;
   278		int entry;
   279		unsigned long flags;
   280	
   281		netif_dbg(lp, tx_queued, dev, "%s: skb=%p\n", __func__, skb);
   282	
   283		length = skb->len;
   284		if (length < ETH_ZLEN) {
   285			if (skb_padto(skb, ETH_ZLEN))
   286				return NETDEV_TX_OK;
   287			length = ETH_ZLEN;
   288		}
   289	
   290		/*
   291		 * Map the packet data into the logical DMA address space
   292		 */
   293	
   294		laddr = dma_map_single(lp->device, skb->data, length, DMA_TO_DEVICE);
 > 295		if (dma_mapping_error(lp->device, laddr))
   296			pr_err_ratelimited("%s: failed to map tx DMA buffer.\n", dev->name);
   297			dev_kfree_skb_any(skb);
   298			return NETDEV_TX_OK;
   299		}
   300	
   301		spin_lock_irqsave(&lp->lock, flags);
   302	
 > 303		entry = (lp->eol_tx + 1) & SONIC_TDS_MASK;
   304	
   305		sonic_tda_put(dev, entry, SONIC_TD_STATUS, 0);       /* clear status */
   306		sonic_tda_put(dev, entry, SONIC_TD_FRAG_COUNT, 1);   /* single fragment */
   307		sonic_tda_put(dev, entry, SONIC_TD_PKTSIZE, length); /* length of packet */
   308		sonic_tda_put(dev, entry, SONIC_TD_FRAG_PTR_L, laddr & 0xffff);
   309		sonic_tda_put(dev, entry, SONIC_TD_FRAG_PTR_H, laddr >> 16);
   310		sonic_tda_put(dev, entry, SONIC_TD_FRAG_SIZE, length);
   311		sonic_tda_put(dev, entry, SONIC_TD_LINK,
   312			sonic_tda_get(dev, entry, SONIC_TD_LINK) | SONIC_EOL);
   313	
   314		sonic_tda_put(dev, lp->eol_tx, SONIC_TD_LINK, ~SONIC_EOL &
   315			      sonic_tda_get(dev, lp->eol_tx, SONIC_TD_LINK));
   316	
   317		netif_dbg(lp, tx_queued, dev, "%s: issuing Tx command\n", __func__);
   318	
   319		SONIC_WRITE(SONIC_CMD, SONIC_CR_TXP);
   320	
   321		lp->tx_len[entry] = length;
   322		lp->tx_laddr[entry] = laddr;
   323		lp->tx_skb[entry] = skb;
   324	
   325		lp->eol_tx = entry;
   326	
   327		entry = (entry + 1) & SONIC_TDS_MASK;
   328		if (lp->tx_skb[entry]) {
   329			/* The ring is full, the ISR has yet to process the next TD. */
   330			netif_dbg(lp, tx_queued, dev, "%s: stopping queue\n", __func__);
   331			netif_stop_queue(dev);
   332			/* after this packet, wait for ISR to free up some TDAs */
   333		}
   334	
   335		spin_unlock_irqrestore(&lp->lock, flags);
   336	
   337		return NETDEV_TX_OK;
   338	}
   339	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

View attachment "config" of type "text/plain" (282713 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ