From: sashiko-bot@kernel.org
To: "Igor Putko" <igorpetindev@gmail.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH v2] serial: core: shut down initialized port on removal
Date: Sat, 03 Oct 2026 17:56:33 +0000 [thread overview]
Message-ID: <20261003175634.0710A1F0089B@smtp.kernel.org> (raw)
In-Reply-To: <20261003163337.45577-1-igorpetindev@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] serial: PM state leak in serial_core_remove_one_port() due to missed uart_change_pm()
--
commit 9122ece37c80d138a14cda352b9aec7db9935327
Author: Igor Putko <igorpetindev@gmail.com>
serial: core: shut down initialized port on removal
This commit clears port->console under the port mutex and explicitly calls
uart_shutdown() if the port is initialized during removal. It aims to fix a
use-after-free by ensuring the port is shut down and its IRQ freed when
unbinding a device that was previously used as a console.
Closes: https://syzkaller.appspot.com/bug?extid=843bf2f48f4d12e6682e
Reported-by: syzbot+843bf2f48f4d12e6682e@syzkaller.appspotmail.com
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index 319a4b427f3a3..05450529871e0 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
[ ... ]
> @@ -3239,6 +3239,13 @@ static void serial_core_remove_one_port(struct uart_driver *drv,
> if (uart_console(uport))
> unregister_console(uport->cons);
>
> + scoped_guard(mutex, &port->mutex) {
> + port->console = false;
> +
> + if (tty_port_initialized(port))
> + uart_shutdown(NULL, state);
[Severity: Medium]
Does calling uart_shutdown() directly here skip the complete TTY port
shutdown sequence?
When unbinding a serial device that was previously opened and closed as a
console, uart_shutdown() only executes a partial teardown. It skips
uport->ops->stop_rx() and transitioning the PM state to OFF, which normally
happen in uart_tty_port_shutdown():
drivers/tty/serial/serial_core.c:uart_tty_port_shutdown() {
...
scoped_guard(uart_port_lock_irq, uport)
uport->ops->stop_rx(uport);
serial_base_port_shutdown(uport);
uart_port_shutdown(port);
...
uart_change_pm(state, UART_PM_STATE_OFF);
}
Could this leave the device in an active power state (UART_PM_STATE_ON)
indefinitely or leave the hardware receiving data and interrupts? Calling
tty_port_shutdown_locked() would execute the complete sequence.
> + }
> +
> /*
> * Free the port IO and memory resources, if any.
> */
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261003163337.45577-1-igorpetindev@gmail.com?part=1
prev parent reply other threads:[~2026-10-03 17:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 19:22 [PATCH] serial: core: shut down initialized port on removal Igor Putko
2026-09-24 19:39 ` sashiko-bot
2026-09-25 5:34 ` Greg Kroah-Hartman
2026-09-26 13:05 ` IgorpetinDev
2026-10-01 8:58 ` Greg KH
2026-10-03 16:33 ` [PATCH v2] " Igor Putko
2026-10-03 17:56 ` sashiko-bot [this message]
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=20261003175634.0710A1F0089B@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=igorpetindev@gmail.com \
--cc=linux-serial@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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