summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2026-10-27 12:06:44 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-11-03 13:28:53 +0100
commit0f0664a63efdfd70d1c555080781f4e8464445aa (patch)
treeb5dc6b78a8d2bfa38a094af3d6c45d332a5d4afb
parent899e3c6e30ff34cf7a260b806fdedb56749e36e9 (diff)
serial: fsl_lpuart: fix tty ref of wakeup event
To report a wakeup event, lpuart_resume_noirq() gets the tty with tty_port_tty_get() and never puts it: each wakeup by the UART leaks a reference, and the tty is not freed when it is closed. With no_console_suspend, the function also gets there for a console which is not open. Then tty_port_tty_get() returns NULL, which is dereferenced. Fixes: 18bdfccf3c30 ("tty: serial: fsl_lpuart: Add missing wakeup event reporting") Cc: stable <stable@kernel.org> Cc: Jiri Slaby <jirislaby@kernel.org> Cc: Frank Li <Frank.Li@nxp.com> Cc: Peng Fan <peng.fan@nxp.com> Cc: Shitalkumar Gandhi <shital.gandhi45@gmail.com> Cc: Sherry Sun <sherry.sun@nxp.com> Signed-off-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://patch.msgid.link/20261027-tty-llm-v1-18-99b0202ae546@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/fsl_lpuart.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index c8575c965203..e54b4c44db42 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -3113,8 +3113,14 @@ static int lpuart_resume_noirq(struct device *dev)
/* check whether lpuart wakeup was triggered */
wake_active = stat & (UARTSTAT_RDRF | UARTSTAT_RXEDGIF);
- if (wake_active && irqd_is_wakeup_set(irq_get_irq_data(sport->port.irq)))
- pm_wakeup_event(tty_port_tty_get(port)->dev, 0);
+ if (wake_active && irqd_is_wakeup_set(irq_get_irq_data(sport->port.irq))) {
+ struct tty_struct *tty = tty_port_tty_get(port);
+
+ if (tty) {
+ pm_wakeup_event(tty->dev, 0);
+ tty_kref_put(tty);
+ }
+ }
}
}