]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: wan/fsl_ucc_hdlc: Fix dma_free_coherent() in uhdlc_memclean()
authorThomas Fourier <fourier.thomas@gmail.com>
Fri, 6 Feb 2026 08:53:33 +0000 (09:53 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 10 Feb 2026 14:46:49 +0000 (15:46 +0100)
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.

Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Fixes: c19b6d246a35 ("drivers/net: support hdlc function for QE-UCC")
Cc: <stable@vger.kernel.org>
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
Link: https://patch.msgid.link/20260206085334.21195-2-fourier.thomas@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/wan/fsl_ucc_hdlc.c

index f999798a561271f018a921847714543a01512a92..dff84731343cc6572978408ea1695b65ee03da62 100644 (file)
@@ -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;
+
        }
 }