[PATCH net 2/3] net: stmmac: free RX resources when TX allocation fails

Maxime Chevallier maxime.chevallier at bootlin.com
Wed Oct 14 04:37:19 PDT 2026


Hi,

On 10/14/26 08:27, Karl Mehltretter wrote:
> alloc_dma_desc_resources() allocates every RX queue before allocating
> TX queues. If TX allocation fails, its error path only frees TX
> resources and leaks all RX resources.
> 
> Free the RX resources after the TX allocator unwinds its queues.
> 
> Found by inspection. On a BeagleV Ahead (TH1520), forcing TX DMA
> metadata allocation to fail left the RX cleanup event absent. With this
> change, both TX and RX resources were released.
> 
> Fixes: 71fedb0198cb ("net: stmmac: break some functions into RX and TX scopes")
> Assisted-by: LLM
> Signed-off-by: Karl Mehltretter <kmehltretter at gmail.com>

Also covered by https://lore.kernel.org/netdev/20261012142458.2845385-1-dinghui1111@163.com/.

Thanks,

Maxime

> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 495ff7aef..8fd7d2173 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -2425,6 +2425,8 @@ static int alloc_dma_desc_resources(struct stmmac_priv *priv,
>  		return ret;
>  
>  	ret = alloc_dma_tx_desc_resources(priv, dma_conf);
> +	if (ret)
> +		free_dma_rx_desc_resources(priv, dma_conf);
>  
>  	return ret;
>  }




More information about the linux-arm-kernel mailing list