Re: [PATCH] net: stmmac: fix NULL pointer dereference in tx/rx resource cleanup
From: Andrew Lunn
Date: Sun Aug 30 2026 - 10:06:51 EST
On Sun, Aug 30, 2026 at 12:06:08PM +0800, Ding Hui wrote:
> From: Ding Hui <dinghui@xxxxxxxxxxx>
>
> The DMA descriptor ring allocation in __init_dma_rx_desc_rings() and
> __alloc_dma_tx_desc_resources() is split into multiple steps, each of
> which may fail and return early while the per-queue cleanup paths still
> call the free helpers for the partially-initialized queue.
"and return early", is the real problem here. When a function returns
an error, it should first undo what it has done, up to the point of
the error.
Rather than add extra NULL checks, please work on
__init_dma_rx_desc_rings() and __alloc_dma_tx_desc_resources() and
make them cleanup on error.
I would say the problem you are trying to fix does not bother anybody,
so is not for stable. So i aim the patches for net-next.
Andrew