| From eedf2cf3505c1562a2fb24f8b997056f023d242b Mon Sep 17 00:00:00 2001 | |
| From: Josef Bacik <josef@toxicpanda.com> | |
| Date: Tue, 27 Oct 2026 12:06:48 +0100 | |
| Subject: serial: samsung: put the previous baud clock | |
| From: Josef Bacik <josef@toxicpanda.com> | |
| commit eedf2cf3505c1562a2fb24f8b997056f023d242b upstream. | |
| s3c24xx_serial_getclk() returns the best baud clock with the reference | |
| which clk_get() has taken. s3c24xx_serial_set_termios() stores it in | |
| ourport->baudclk and disables the clock which was there before, but does | |
| not put it. | |
| clk_get() hands out a new handle on every call, so the new clock never | |
| equals the old one, and every call of ->set_termios() leaks a handle: a | |
| struct clk and a copy of the connection name. Whoever has the port open | |
| can repeat that at will with tcsetattr(). | |
| Put the old clock when it is replaced, and the new one in case it is not | |
| stored. | |
| Fixes: 5f5a7a5578c5 ("serial: samsung: switch to clkdev based clock lookup") | |
| Cc: stable <stable@kernel.org> | |
| Cc: Krzysztof Kozlowski <krzk@kernel.org> | |
| Cc: Peter Griffin <peter.griffin@linaro.org> | |
| Cc: Alim Akhtar <alim.akhtar@samsung.com> | |
| Cc: Jiri Slaby <jirislaby@kernel.org> | |
| Cc: Kukjin Kim <kgene.kim@samsung.com> | |
| Cc: Thomas Abraham <thomas.abraham@linaro.org> | |
| 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-22-99b0202ae546@linuxfoundation.org | |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
| --- | |
| drivers/tty/serial/samsung_tty.c | 3 +++ | |
| 1 file changed, 3 insertions(+) | |
| --- a/drivers/tty/serial/samsung_tty.c | |
| +++ b/drivers/tty/serial/samsung_tty.c | |
| @@ -1498,11 +1498,14 @@ static void s3c24xx_serial_set_termios(s | |
| if (!IS_ERR(ourport->baudclk)) { | |
| clk_disable_unprepare(ourport->baudclk); | |
| + clk_put(ourport->baudclk); | |
| ourport->baudclk = ERR_PTR(-EINVAL); | |
| } | |
| ourport->baudclk = clk; | |
| ourport->baudclk_rate = clk ? clk_get_rate(clk) : 0; | |
| + } else { | |
| + clk_put(clk); | |
| } | |
| if (ourport->info->has_divslot) { |