Skip to contentSkip to conversation

net: wan/fsl_ucc_hdlc: Fix dma_free_coherent() in uhdlc_memclean()

PATCH Applied Thomas Fourier 2 participants 2 messages Feb 6 – Feb 10

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: wan/fsl_ucc_hdlc: Fix dma_free_coherent() in uhdlc_memclean()

The priv->rx_buffer and priv->tx_buffer are alloc'd together as contiguous buffers in uhdlc_init() but freed as two buffers in uhdlc_memclean().

Change the cleanup to only call dma_free_coherent() once on the whole buffer.

Fixes c19b6d246a35 ("drivers/net: support hdlc function for QE-UCC")

---
v1->v2:
- Cleanup priv->tx_buffer and priv->dma_tx_addr
- Fix buffer name in commit message

 drivers/net/wan/fsl_ucc_hdlc.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/wan/fsl_ucc_hdlc.c +2 -6
index f999798a5612..dff84731343c 100644
@@ -790,18 +790,14 @@ static void uhdlc_memclean(struct ucc_hdlc_private *priv)
 
 	if (priv->rx_buffer) {
 		dma_free_coherent(priv->dev,
-				  RX_BD_RING_LEN * MAX_RX_BUF_LENGTH,
+				  (RX_BD_RING_LEN + TX_BD_RING_LEN) * MAX_RX_BUF_LENGTH,
 				  priv->rx_buffer, priv->dma_rx_addr);
 		priv->rx_buffer = NULL;
 		priv->dma_rx_addr = 0;
-	}
 
-	if (priv->tx_buffer) {
-		dma_free_coherent(priv->dev,
-				  TX_BD_RING_LEN * MAX_RX_BUF_LENGTH,
-				  priv->tx_buffer, priv->dma_tx_addr);
 		priv->tx_buffer = NULL;
 		priv->dma_tx_addr = 0;
+
 	}
 }
 
Signature · 1 line
2.43.0
#1 lore raw
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

Quoted 8 lines · On Fri, 6 Feb 2026 09:53:33 +0100 you wrote:

The priv->rx_buffer and priv->tx_buffer are alloc'd together as contiguous buffers in uhdlc_init() but freed as two buffers in uhdlc_memclean().

Change the cleanup to only call dma_free_coherent() once on the whole buffer.

[...]

Here is the summary with links:
- [net,v2] net: wan/fsl_ucc_hdlc: Fix dma_free_coherent() in uhdlc_memclean()

    https://git.kernel.org/netdev/net/c/36bd7d5deef9

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html