From: Abid Ali <dev.taqnialabs@gmail.com>
To: devnull+dev.taqnialabs.gmail.com@kernel.org
Cc: alexandre.torgue@foss.st.com, andrew+netdev@lunn.ch,
davem@davemloft.net, dev.taqnialabs@gmail.com,
edumazet@google.com, kuba@kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
mcoquelin.stm32@gmail.com, netdev@vger.kernel.org,
pabeni@redhat.com
Subject: Re: [PATCH v2] net: stmmac: fix RX DMA leak on TX alloc failure
Date: Sat, 23 May 2026 12:17:08 +0000 [thread overview]
Message-ID: <20260523121708.564-1-dev.taqnialabs@gmail.com> (raw)
In-Reply-To: <20260522-stmmac-rx-desc-cleanup-v2-1-76e78eb471e1@gmail.com>
> ret = alloc_dma_tx_desc_resources(priv, dma_conf);
>+ if (ret)
>+ free_dma_rx_desc_resources(priv, dma_conf);
>
> return ret;
> }
The sashiko-gemini analysis [1] flagged two issues.
1) Double-free via XDP path:
stmmac_xdp_set_prog() ignores the return of stmmac_xdp_open(), so
if alloc_dma_tx_desc_resources() fails inside that path,
rx_q->buf_pool and rx_q->dma_rx are freed for Rx queues.
The interface stays UP, so a later stmmac_release() calls
free_dma_desc_resources() on the same freed pointers.
Without this patch, the same failure path leaks RX resources
instead. Either way the root cause seems to be stmmac_xdp_set_prog() not
handling errors from stmmac_xdp_open().
The reported issue seems to be valid, but I'm not sure why XDP doesn't handle
a possible error in reinit in the first place.
2) NULL deref on partial queue alloc:
If alloc_dma_rx_desc_resources() fails for queue N,
e.g. rx_q->page_pool = page_pool_create() fails, buf_pool is NULL.
The cleanup free_dma_rx_desc_resources() iterates through all
queues and will hit a NULL pointer deref in:
static void stmmac_free_rx_buffer(struct stmmac_priv *priv,
struct stmmac_rx_queue *rx_q,
int i)
{
struct stmmac_rx_buffer *buf = &rx_q->buf_pool[i];
The same could happen without the patch, and similar risk exists for
rx_q->buf_pool, rx_q->dma_rx, and rx_q->dma_erx which are all freed
without guards in __free_dma_rx_desc_resources().
I can add the necessary NULL guards in __free_dma_rx_desc_resources()
for V3 if necessary.
[1] https://sashiko.dev/#/patchset/20260522-stmmac-rx-desc-cleanup-v2-1-76e78eb471e1@gmail.com
- Abid
prev parent reply other threads:[~2026-05-23 12:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 7:09 [PATCH v2] net: stmmac: fix RX DMA leak on TX alloc failure Abid Ali via B4 Relay
2026-05-23 12:17 ` Abid Ali [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=20260523121708.564-1-dev.taqnialabs@gmail.com \
--to=dev.taqnialabs@gmail.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=devnull+dev.taqnialabs.gmail.com@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--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 \
/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