diff mbox series

[wpan-next,5/9] net: ieee802154: ca8210: Stop leaking skb's

Message ID 20220120003645.308498-6-miquel.raynal@bootlin.com (mailing list archive)
State Not Applicable
Delegated to: Johannes Berg
Headers show
Series ieee802154: A bunch of fixes | expand

Commit Message

Miquel Raynal Jan. 20, 2022, 12:36 a.m. UTC
Upon error the ieee802154_xmit_complete() helper is not called. Only
ieee802154_wake_queue() is called manually. We then leak the skb
structure.

Free the skb structure upon error before returning.

Fixes: ded845a781a5 ("ieee802154: Add CA8210 IEEE 802.15.4 device driver")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/net/ieee802154/ca8210.c | 1 +
 1 file changed, 1 insertion(+)

Comments

kernel test robot Jan. 20, 2022, 7:31 a.m. UTC | #1
Hi Miquel,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.16 next-20220120]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Miquel-Raynal/ieee802154-A-bunch-of-fixes/20220120-083906
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 1d1df41c5a33359a00e919d54eaebfb789711fdc
config: i386-randconfig-a013 (https://download.01.org/0day-ci/archive/20220120/202201201557.38baVRVX-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project f7b7138a62648f4019c55e4671682af1f851f295)
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/0day-ci/linux/commit/77d3026b30aff560ef269d03aecc09f8c46a9173
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Miquel-Raynal/ieee802154-A-bunch-of-fixes/20220120-083906
        git checkout 77d3026b30aff560ef269d03aecc09f8c46a9173
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/net/ieee802154/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/net/ieee802154/ca8210.c:1775:22: error: use of undeclared identifier 'atusb'
                           dev_kfree_skb_any(atusb->tx_skb);
                                             ^
   1 error generated.


vim +/atusb +1775 drivers/net/ieee802154/ca8210.c

  1737	
  1738	/**
  1739	 * ca8210_async_xmit_complete() - Called to announce that an asynchronous
  1740	 *                                transmission has finished
  1741	 * @hw:          ieee802154_hw of ca8210 that has finished exchange
  1742	 * @msduhandle:  Identifier of transmission that has completed
  1743	 * @status:      Returned 802.15.4 status code of the transmission
  1744	 *
  1745	 * Return: 0 or linux error code
  1746	 */
  1747	static int ca8210_async_xmit_complete(
  1748		struct ieee802154_hw  *hw,
  1749		u8                     msduhandle,
  1750		u8                     status)
  1751	{
  1752		struct ca8210_priv *priv = hw->priv;
  1753	
  1754		if (priv->nextmsduhandle != msduhandle) {
  1755			dev_err(
  1756				&priv->spi->dev,
  1757				"Unexpected msdu_handle on data confirm, Expected %d, got %d\n",
  1758				priv->nextmsduhandle,
  1759				msduhandle
  1760			);
  1761			return -EIO;
  1762		}
  1763	
  1764		priv->async_tx_pending = false;
  1765		priv->nextmsduhandle++;
  1766	
  1767		if (status) {
  1768			dev_err(
  1769				&priv->spi->dev,
  1770				"Link transmission unsuccessful, status = %d\n",
  1771				status
  1772			);
  1773			if (status != MAC_TRANSACTION_OVERFLOW) {
  1774				ieee802154_wake_queue(priv->hw);
> 1775				dev_kfree_skb_any(atusb->tx_skb);
  1776				return 0;
  1777			}
  1778		}
  1779		ieee802154_xmit_complete(priv->hw, priv->tx_skb, true);
  1780	
  1781		return 0;
  1782	}
  1783	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Miquel Raynal Jan. 20, 2022, 9:25 a.m. UTC | #2
lkp@intel.com wrote on Thu, 20 Jan 2022 15:31:39 +0800:

> Hi Miquel,
> 
> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on linus/master]
> [also build test ERROR on v5.16 next-20220120]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
> 
> url:    https://github.com/0day-ci/linux/commits/Miquel-Raynal/ieee802154-A-bunch-of-fixes/20220120-083906
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 1d1df41c5a33359a00e919d54eaebfb789711fdc
> config: i386-randconfig-a013 (https://download.01.org/0day-ci/archive/20220120/202201201557.38baVRVX-lkp@intel.com/config)
> compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project f7b7138a62648f4019c55e4671682af1f851f295)
> 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/0day-ci/linux/commit/77d3026b30aff560ef269d03aecc09f8c46a9173
>         git remote add linux-review https://github.com/0day-ci/linux
>         git fetch --no-tags linux-review Miquel-Raynal/ieee802154-A-bunch-of-fixes/20220120-083906
>         git checkout 77d3026b30aff560ef269d03aecc09f8c46a9173
>         # save the config file to linux build tree
>         mkdir build_dir
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/net/ieee802154/
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):
> 
> >> drivers/net/ieee802154/ca8210.c:1775:22: error: use of undeclared identifier 'atusb'  
>                            dev_kfree_skb_any(atusb->tx_skb);
>                                              ^
>    1 error generated.
> 
> 
> vim +/atusb +1775 drivers/net/ieee802154/ca8210.c
> 
>   1737	
>   1738	/**
>   1739	 * ca8210_async_xmit_complete() - Called to announce that an asynchronous
>   1740	 *                                transmission has finished
>   1741	 * @hw:          ieee802154_hw of ca8210 that has finished exchange
>   1742	 * @msduhandle:  Identifier of transmission that has completed
>   1743	 * @status:      Returned 802.15.4 status code of the transmission
>   1744	 *
>   1745	 * Return: 0 or linux error code
>   1746	 */
>   1747	static int ca8210_async_xmit_complete(
>   1748		struct ieee802154_hw  *hw,
>   1749		u8                     msduhandle,
>   1750		u8                     status)
>   1751	{
>   1752		struct ca8210_priv *priv = hw->priv;
>   1753	
>   1754		if (priv->nextmsduhandle != msduhandle) {
>   1755			dev_err(
>   1756				&priv->spi->dev,
>   1757				"Unexpected msdu_handle on data confirm, Expected %d, got %d\n",
>   1758				priv->nextmsduhandle,
>   1759				msduhandle
>   1760			);
>   1761			return -EIO;
>   1762		}
>   1763	
>   1764		priv->async_tx_pending = false;
>   1765		priv->nextmsduhandle++;
>   1766	
>   1767		if (status) {
>   1768			dev_err(
>   1769				&priv->spi->dev,
>   1770				"Link transmission unsuccessful, status = %d\n",
>   1771				status
>   1772			);
>   1773			if (status != MAC_TRANSACTION_OVERFLOW) {
>   1774				ieee802154_wake_queue(priv->hw);
> > 1775				dev_kfree_skb_any(atusb->tx_skb);  

Looks like I messed with the configuration and this driver was not
compile-tested anymore. I'll fix this.

>   1776				return 0;
>   1777			}
>   1778		}
>   1779		ieee802154_xmit_complete(priv->hw, priv->tx_skb, true);
>   1780	
>   1781		return 0;
>   1782	}
>   1783	
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org


Thanks,
Miquèl
diff mbox series

Patch

diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
index ece6ff6049f6..5d1b356cb9d3 100644
--- a/drivers/net/ieee802154/ca8210.c
+++ b/drivers/net/ieee802154/ca8210.c
@@ -1772,6 +1772,7 @@  static int ca8210_async_xmit_complete(
 		);
 		if (status != MAC_TRANSACTION_OVERFLOW) {
 			ieee802154_wake_queue(priv->hw);
+			dev_kfree_skb_any(atusb->tx_skb);
 			return 0;
 		}
 	}