From: Francois Romieu <romieu@fr.zoreil.com>
To: Zhang Changzhong <zhangchangzhong@huawei.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Moritz Fischer <mdf@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net: nixge: fix potential memory leak in nixge_start_xmit()
Date: Mon, 14 Nov 2022 11:40:04 +0100 [thread overview]
Message-ID: <Y3IbBCioK1Clt/3a@electric-eye.fr.zoreil.com> (raw)
In-Reply-To: <1668416136-33530-1-git-send-email-zhangchangzhong@huawei.com>
Zhang Changzhong <zhangchangzhong@huawei.com> :
> The nixge_start_xmit() returns NETDEV_TX_OK but does not free skb on two
> error handling cases, which can lead to memory leak.
>
> To fix this, return NETDEV_TX_BUSY in case of nixge_check_tx_bd_space()
> fails and add dev_kfree_skb_any() in case of dma_map_single() fails.
This patch merge two unrelated changes. Please split.
> Fixes: 492caffa8a1a ("net: ethernet: nixge: Add support for National Instruments XGE netdev")
> Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
> ---
> drivers/net/ethernet/ni/nixge.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c
> index 19d043b593cc..b9091f9bbc77 100644
> --- a/drivers/net/ethernet/ni/nixge.c
> +++ b/drivers/net/ethernet/ni/nixge.c
> @@ -521,13 +521,15 @@ static netdev_tx_t nixge_start_xmit(struct sk_buff *skb,
> if (nixge_check_tx_bd_space(priv, num_frag)) {
> if (!netif_queue_stopped(ndev))
> netif_stop_queue(ndev);
> - return NETDEV_TX_OK;
> + return NETDEV_TX_BUSY;
> }
The driver should probably check the available room before returning
from hard_start_xmit and turn the check above unlikely().
Btw there is no lock and the Tx completion is irq driven: the driver
is racy. :o(
--
Ueimor
next prev parent reply other threads:[~2022-11-14 10:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-14 8:55 Zhang Changzhong
2022-11-14 10:40 ` Francois Romieu [this message]
2022-11-15 13:20 ` Zhang Changzhong
2022-11-16 22:36 ` Saeed Mahameed
2022-11-17 3:04 ` Zhang Changzhong
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=Y3IbBCioK1Clt/3a@electric-eye.fr.zoreil.com \
--to=romieu@fr.zoreil.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mdf@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
all inboxes | Powered by JetHome®