Skip to contentSkip to conversation

FAILED: patch "[PATCH] serial: samsung: don't leak the tty on an RX IRQ" failed to apply to 5.10-stable tree

PATCH [email protected] 1 participant 1 message Nov 25

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 7ada442f5ef77f8d53f608a0141a5e88a888ca9f
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026112552-acre-justifier-533d@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 7ada442f5ef77f8d53f608a0141a5e88a888ca9f Mon Sep 17 00:00:00 2001
From: Josef Bacik <[email protected]>
Date: Tue, 27 Oct 2026 12:06:47 +0100
Subject: [PATCH] serial: samsung: don't leak the tty on an RX IRQ

s3c24xx_serial_rx_chars_dma() starts by taking a reference to the tty. If the interrupt is not a receive timeout, it switches the port from PIO back to DMA and leaves through the "finish" label, which does not drop the reference.

A port with RX DMA changes to PIO on every receive timeout, that is at the end of every burst of data, and comes back this way when the next burst starts. So each burst takes a reference which is never dropped, and the tty structure is not freed when the port is closed for the last time.

Drop the reference on both paths.

Fixes b543c301c2c5 ("serial: samsung: add DMA support for RX")
Cc stable <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Peter Griffin <[email protected]>
Cc Alim Akhtar <[email protected]>
Cc Jiri Slaby <[email protected]>
Cc Robert Baldyga <[email protected]>
drivers/tty/serial/samsung_tty.c +2 -3
index 640f85e2d636..c9a870a8d155 100644
@@ -736,14 +736,13 @@ static irqreturn_t s3c24xx_serial_rx_chars_dma(struct s3c24xx_uart_port *ourport
 
 	s3c24xx_serial_rx_drain_fifo(ourport);
 
-	if (tty) {
+	if (tty)
 		tty_flip_buffer_push(t);
-		tty_kref_put(tty);
-	}
 
 	wr_regl(port, S3C2410_UTRSTAT, S3C2410_UTRSTAT_TIMEOUT);
 
 finish:
+	tty_kref_put(tty);
 	uart_port_unlock(port);
 
 	return IRQ_HANDLED;