From: Ding Hui <dinghui1111@163.com>
To: Maxime Chevallier <maxime.chevallier@bootlin.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
netdev@vger.kernel.org (open list:STMMAC ETHERNET DRIVER),
linux-stm32@st-md-mailman.stormreply.com (moderated
list:ARM/STM32 ARCHITECTURE),
linux-arm-kernel@lists.infradead.org (moderated list:ARM/STM32
ARCHITECTURE), linux-kernel@vger.kernel.org (open list)
Cc: dinghui@lixiang.com, xiasanbo@lixiang.com,
yangchen11@lixiang.com, liuxuanjun@lixiang.com
Subject: [PATCH net-next v6 0/4] net: stmmac: fix DMA descriptor ring cleanup issues
Date: Sat, 24 Oct 2026 15:13:14 +0800 [thread overview]
Message-ID: <20261024071319.875921-1-dinghui1111@163.com> (raw)
From: Ding Hui <dinghui@lixiang.com>
Hello,
This series fixes the NULL pointer dereferences in the stmmac TX/RX
DMA resource cleanup paths and the associated error path issues,
found on a DWMAC platform whose descriptor ring allocation may fail
under memory pressure.
Patch 1 adds NULL guards in the free helpers and makes them clear
the pointers they free, so that a NULL pointer reliably means "not
allocated" for the long-lived priv->dma_conf.
Patch 2 makes the per-queue allocation functions undo their own
allocations on error, instead of leaving the cleanup to the outer
error paths that would then walk partially-initialized queues.
Patch 3 releases the descriptor resources through priv->dma_conf
when __stmmac_open() fails after copying the temporary dma_conf, so
the long-lived configuration stays consistent with the resource
cleanup.
Patch 4 holds RTNL around the descriptors_status debugfs reader and
skips queues whose rings are not allocated.
This series is rebased on top of the current net-next.
Changes in v6:
- Split the single patch into a four-patch series as requested
during review: NULL guards and pointer clearing, allocation
error paths, descriptor resource release through priv->dma_conf
on open failure, and the descriptors_status debugfs locking.
- Merge the descriptor resource release with the ptp_error unwind
from 8181678a92f0 and rebase on top of the current net-next.
- Use the "net-next" subject prefix, which was requested back in
v1 but mistakenly kept as "net" in all previous revisions.
- Link to v5:
https://lore.kernel.org/netdev/20261012142458.2845385-1-dinghui1111@163.com/
Changes in v5:
- Release the descriptor resources through priv->dma_conf when
__stmmac_open() fails, avoiding stale pointers in the
long-lived configuration.
- Hold RTNL while descriptors_status reads the descriptor rings.
- Link to v4:
https://lore.kernel.org/netdev/20261001035045.3305816-1-dinghui1111@163.com/
Changes in v4:
- Free the RX resources in alloc_dma_desc_resources() when the TX
allocation fails.
- Skip queues whose descriptor rings are not allocated in
stmmac_rings_status_show() and print a hint instead.
- Link to v3:
https://lore.kernel.org/netdev/20260919121436.1642724-1-dinghui1111@163.com/
Changes in v3:
- Use addr directly in __alloc_dma_rx_desc_resources() error path
instead of the if/else block on rx_q->dma_erx/dma_rx.
- Clear the freed pointers in __free_dma_rx_desc_resources() and
__free_dma_tx_desc_resources().
- Link to v2:
https://lore.kernel.org/netdev/20260905154654.1725313-1-dinghui1111@163.com/
Changes in v2:
- Instead of only adding NULL checks in the free helpers, also fix
__alloc_dma_rx_desc_resources() and
__alloc_dma_tx_desc_resources() to clean up their own
allocations on error, as suggested by Andrew.
- Link to v1:
https://lore.kernel.org/netdev/20260830040610.1156008-1-dinghui1111@163.com/
Ding Hui (4):
net: stmmac: guard against NULL pointers when freeing TX/RX buffers
net: stmmac: clean up partially allocated DMA rings on error
net: stmmac: release descriptor resources through priv->dma_conf on
open failure
net: stmmac: hold RTNL when reading descriptor rings in
descriptors_status
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 115 +++++++++++++++---
1 file changed, 98 insertions(+), 17 deletions(-)
--
2.34.1
next reply other threads:[~2026-10-24 7:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-24 7:13 Ding Hui [this message]
2026-10-24 7:13 ` [PATCH net-next v6 1/4] net: stmmac: guard against NULL pointers when freeing TX/RX buffers Ding Hui
2026-10-24 7:13 ` [PATCH net-next v6 2/4] net: stmmac: clean up partially allocated DMA rings on error Ding Hui
2026-10-24 7:13 ` [PATCH net-next v6 3/4] net: stmmac: release descriptor resources through priv->dma_conf on open failure Ding Hui
2026-10-24 7:13 ` [PATCH net-next v6 4/4] net: stmmac: hold RTNL when reading descriptor rings in descriptors_status Ding Hui
2026-10-24 7:21 ` [PATCH net-next v6 0/4] net: stmmac: fix DMA descriptor ring cleanup issues netdev-bot+sinfo
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=20261024071319.875921-1-dinghui1111@163.com \
--to=dinghui1111@163.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=dinghui@lixiang.com \
--cc=edumazet@kernel.org \
--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=liuxuanjun@lixiang.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=xiasanbo@lixiang.com \
--cc=yangchen11@lixiang.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®