netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Zhang Changzhong <zhangchangzhong@huawei.com>
Cc: Edward Cree <ecree.xilinx@gmail.com>,
	Martin Habets <habetsm.xilinx@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] sfc: fix potential memleak in __ef100_hard_start_xmit()
Date: Thu, 17 Nov 2022 13:36:21 +0200	[thread overview]
Message-ID: <Y3YctdnKDDvikQcl@unreal> (raw)
In-Reply-To: <1668671409-10909-1-git-send-email-zhangchangzhong@huawei.com>

On Thu, Nov 17, 2022 at 03:50:09PM +0800, Zhang Changzhong wrote:
> The __ef100_hard_start_xmit() returns NETDEV_TX_OK without freeing skb
> in error handling case, add dev_kfree_skb_any() to fix it.
> 
> Fixes: 51b35a454efd ("sfc: skeleton EF100 PF driver")
> Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
> ---
>  drivers/net/ethernet/sfc/ef100_netdev.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/sfc/ef100_netdev.c b/drivers/net/ethernet/sfc/ef100_netdev.c
> index 88fa295..ddcc325 100644
> --- a/drivers/net/ethernet/sfc/ef100_netdev.c
> +++ b/drivers/net/ethernet/sfc/ef100_netdev.c
> @@ -218,6 +218,7 @@ netdev_tx_t __ef100_hard_start_xmit(struct sk_buff *skb,
>  		   skb->len, skb->data_len, channel->channel);
>  	if (!efx->n_channels || !efx->n_tx_channels || !channel) {
>  		netif_stop_queue(net_dev);
> +		dev_kfree_skb_any(skb);
>  		goto err;
>  	}

ef100 doesn't release in __ef100_enqueue_skb() either. SKB shouldn't be
NULL or ERR at this stage.

diff --git a/drivers/net/ethernet/sfc/ef100_tx.c b/drivers/net/ethernet/sfc/ef100_tx.c
index 29ffaf35559d..426706b91d02 100644
--- a/drivers/net/ethernet/sfc/ef100_tx.c
+++ b/drivers/net/ethernet/sfc/ef100_tx.c
@@ -497,7 +497,7 @@ int __ef100_enqueue_skb(struct efx_tx_queue *tx_queue, struct sk_buff *skb,

 err:
        efx_enqueue_unwind(tx_queue, old_insert_count);
-       if (!IS_ERR_OR_NULL(skb))
+       if (rc)
                dev_kfree_skb_any(skb);

        /* If we're not expecting another transmit and we had something to push


>  
> -- 
> 2.9.5
> 

  reply	other threads:[~2022-11-17 11:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17  7:50 [PATCH net] sfc: fix potential memleak in __ef100_hard_start_xmit() Zhang Changzhong
2022-11-17 11:36 ` Leon Romanovsky [this message]
2022-11-17 12:41   ` Zhang Changzhong
2022-11-17 13:05     ` Leon Romanovsky
2022-11-18  9:15       ` Martin Habets
2022-11-18 11:53         ` Zhang Changzhong
2022-11-18 17:11         ` Leon Romanovsky
2022-11-22  8:28           ` Paolo Abeni
2022-11-22  9:47             ` Leon Romanovsky
2022-11-18  9:13 ` Martin Habets
2022-11-22 10:40 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y3YctdnKDDvikQcl@unreal \
    --to=leon@kernel.org \
    --cc=davem@davemloft.net \
    --cc=ecree.xilinx@gmail.com \
    --cc=edumazet@google.com \
    --cc=habetsm.xilinx@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=zhangchangzhong@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).