From: Jakub Kicinski <kuba@kernel.org>
To: lihaoxiang@isrc.iscas.ac.cn
Cc: Jakub Kicinski <kuba@kernel.org>,
andrew+netdev@lunn.ch, linux-kernel@vger.kernel.org,
sdf@fomichev.me, bpf@vger.kernel.org, ast@kernel.org,
stable@vger.kernel.org, netdev@vger.kernel.org,
john.fastabend@gmail.com, mcoquelin.stm32@gmail.com,
linux-arm-kernel@lists.infradead.org, daniel@iogearbox.net,
linux-stm32@st-md-mailman.stormreply.com,
boon.leong.ong@intel.com, hawk@kernel.org, davem@davemloft.net,
pabeni@redhat.com, edumazet@google.com,
alexandre.torgue@foss.st.com
Subject: Re: fix a potential memory leak in stmmac_xdp_enable_pool()
Date: Mon, 26 Jan 2026 19:04:47 -0800 [thread overview]
Message-ID: <20260127030447.3838706-1-kuba@kernel.org> (raw)
In-Reply-To: <20260125135412.2070798-1-lihaoxiang@isrc.iscas.ac.cn>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
fix a potential memory leak in stmmac_xdp_enable_pool()
This patch adds xsk_pool_dma_unmap() to the error path when
stmmac_xsk_wakeup() fails, to release the DMA mapping allocated
earlier by xsk_pool_dma_map().
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c
> index d7e4db7224b0..7d89d6066ea3 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c
> @@ -48,8 +48,10 @@ static int stmmac_xdp_enable_pool(struct stmmac_priv *priv,
> napi_enable(&ch->rxtx_napi);
>
> err = stmmac_xsk_wakeup(priv->dev, queue, XDP_WAKEUP_RX);
> - if (err)
> + if (err) {
> + xsk_pool_dma_unmap(pool, STMMAC_RX_DMA_ATTR);
> return err;
> + }
Is the error cleanup here complete? Looking at stmmac_xdp_enable_pool(),
before this point the code has already executed:
set_bit(queue, priv->af_xdp_zc_qps);
stmmac_enable_rx_queue(priv, queue);
stmmac_enable_tx_queue(priv, queue);
napi_enable(&ch->rxtx_napi);
When stmmac_xsk_wakeup() fails, the patch unmaps the DMA pool but does not
appear to reverse these other state changes. Comparing with the cleanup
sequence in stmmac_xdp_disable_pool(), should the error path also:
- call clear_bit(queue, priv->af_xdp_zc_qps)
- disable the queues and NAPI that were just enabled
The DMA descriptors allocated by stmmac_enable_rx_queue() and
stmmac_enable_tx_queue() would also be leaked on this error path.
> }
>
> return 0;
--
pw-bot: cr
prev parent reply other threads:[~2026-01-27 3:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-25 13:54 [PATCH] fix a potential memory leak in stmmac_xdp_enable_pool() Haoxiang Li
2026-01-27 3:04 ` Jakub Kicinski [this message]
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=20260127030447.3838706-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=boon.leong.ong@intel.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=lihaoxiang@isrc.iscas.ac.cn \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=stable@vger.kernel.org \
/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