From: Yige Jiang <yigejiang86@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>
Cc: Yige Jiang <yigejiang86@gmail.com>,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
Michael Walle <michael@walle.cc>,
stable@vger.kernel.org
Subject: [PATCH] tty: serial: fsl_lpuart: avoid releasing DMA channels twice
Date: Mon, 30 Nov 2026 00:30:09 +0800 [thread overview]
Message-ID: <20261127011317.4d10af6e584b.fsl-lpuart@gmail.com> (raw)
lpuart_dma_shutdown() releases the TX and RX DMA channels but leaves
their pointers set. If the device is removed after port shutdown,
lpuart_remove() passes the same channels to dma_release_channel()
again. This can trigger a DMAengine channel reference count warning.
Clear each channel pointer after releasing it so that lpuart_remove()
only releases channels the driver still owns.
A tool-assisted lifetime review found the extra release. Codex helped
draft the fix and this commit message.
Fixes: 159381df1442 ("tty: serial: fsl_lpuart: fix DMA operation when using IOMMU")
Cc: stable@vger.kernel.org
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
Compile-tested on arm64 defconfig with GCC 14.2 and W=1.
drivers/tty/serial/fsl_lpuart.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index e54b4c44db42..17a67805b208 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -1934,10 +1934,15 @@ static void lpuart_dma_shutdown(struct lpuart_port *sport)
sport->lpuart_dma_tx_use = false;
}
- if (sport->dma_tx_chan)
+ if (sport->dma_tx_chan) {
dma_release_channel(sport->dma_tx_chan);
- if (sport->dma_rx_chan)
+ sport->dma_tx_chan = NULL;
+ }
+
+ if (sport->dma_rx_chan) {
dma_release_channel(sport->dma_rx_chan);
+ sport->dma_rx_chan = NULL;
+ }
}
static void lpuart_shutdown(struct uart_port *port)
base-commit: eedf2cf3505c1562a2fb24f8b997056f023d242b
reply other threads:[~2026-11-29 16:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127011317.4d10af6e584b.fsl-lpuart@gmail.com \
--to=yigejiang86@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=michael@walle.cc \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®