Thread (2 messages) 2 messages, 2 authors, 2026-05-05

Re: [PATCH RESEND] net: stmmac: fix RX DMA leak on TX alloc failure

From: Andrew Lunn <andrew@lunn.ch>
Date: 2026-05-05 12:57:38
Also in: linux-arm-kernel, lkml

On Tue, May 05, 2026 at 08:23:07AM +0000, Abid Ali via B4 Relay wrote:
quoted hunk ↗ jump to hunk
From: Abid Ali <redacted>

Free RX DMA resources when alloc_dma_tx_desc_resources() fails in
alloc_dma_desc_resources().

Signed-off-by: Abid Ali <redacted>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 13d3cac05..8bb843b55 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2370,8 +2370,12 @@ 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;
+	}
 
-	return ret;
+	return 0;
You could keep the return ret, and simplify the code:

	ret = alloc_dma_tx_desc_resources(priv, dma_conf);
	if (ret)
		free_dma_rx_desc_resources(priv, dma_conf);

	return ret;

    Andrew

---
pw-bot: cr
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help