net: stmmac: fix DMA descriptor ring cleanup issues
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v6 Latest posting 2/24 patches 1 replyIn review 3 of 4 applied
- v6 posting 1/24 patches 2 repliesSuperseded
Changes in v6 from the cover letter
- 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:
Patches in v6 posting 2/2 3 of 4 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | net: stmmac: guard against NULL pointers when freeing TX/RX buffersdrivers/ | +29 | 0 replies | Applied |
| 2/4 | net: stmmac: clean up partially allocated DMA rings on errordrivers/ | +33 | 0 replies | Applied |
| 3/4 | net: stmmac: release descriptor resources through priv->dma_conf on open failuredrivers/ | +10 | 1 reply | |
| 4/4 | net: stmmac: hold RTNL when reading descriptor rings in descriptors_statusdrivers/ | +26 | 0 replies | Applied |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v6 yet.
Cover letter [PATCH net-next v6 RESEND 0/4] net: stmmac: fix DMA descriptor ring cleanup issues
From: Ding Hui <[email protected]>
Hello,
This is a resend of v6, originally posted on October 24, 2026, when net-next was closed. The four patches are unchanged.
Previous posting (v6):
https://lore.kernel.org/netdev/[email protected]/
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.
The original v6 series was based on net-next commit 734bef548a96 (Merge tag 'net-next-7.4' ofgit://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next).
This resend retains the same base.
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/[email protected]/
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/[email protected]/
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/[email protected]/
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/[email protected]/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/[email protected]/
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