Re: [PATCH net 2/2] net/stmmac: Prevent dma queue NULL free on allocation failure

From: Jakub Raczynski

Date: Wed Jul 08 2026 - 16:22:17 EST


On Tue, Jul 07, 2026 at 07:41:15PM +0200, Jakub Raczynski wrote:
> During allocation of RX/TX descriptor resources and its DMA,
> there is verification of failed dma_alloc_coherent() due to lack of memory.
> In case of that failure, all allocated resources are freed instantly after,
> but there are no checks for dma_free_coherent() whether previous step has
> failed.
> This will generally result in panic due to freeing NULL address.
>
> Fix it by adding NULL verification of memory that is to be freed.
>
> Theoretically code should also set address of pointed memory to zero when
> freeing, but currently the only path of invalid address is non intialized zero,
> and there is no case possible of double-free of same memory.
>
> Fixes: e73b19baa3b1c ("net: stmmac: simplify DMA descriptor allocation/init/freeing")
> Reported-by: Sashiko AI <sashiko-bot@xxxxxxxxxx>
> Signed-off-by: Jakub Raczynski <j.raczynski@xxxxxxxxxxx>
> ---

Sashiko AI gave review that has valid point, patch needs changes.
Please drop it.

--
pw-bot: cr