serial: 8250: Clear CON_PRINTBUFFER on port re-registration

When two PnP devices map to the same physical port, the serial8250 driver
removes and re-registers the console structure for the same port.

During re-registration, the console structure still has CON_PRINTBUFFER set
from the initial registration, which causes console_init_seq() to set
console->seq to syslog_seq. This results in re-printing the entire
system log buffer, which may lead to RCU stall on slow serial consoles.

Clear CON_PRINTBUFFER when re-registering a port to prevent duplicate
log printing.

Fixes: 835d844d1a ("8250_pnp: do pnp probe before legacy probe")
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
Link: https://patch.msgid.link/20260522101042.21976-1-fushuai.wang@linux.dev
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Fushuai Wang 2026-05-22 18:10:42 +08:00 committed by Greg Kroah-Hartman
parent 4d10588066
commit d338ab1d90

View File

@ -720,8 +720,12 @@ int serial8250_register_8250_port(const struct uart_8250_port *up)
/* Preserve specified console flow control. */
cons_flow = uart_cons_flow_enabled(&uart->port);
if (uart->port.dev)
if (uart->port.dev) {
if (uart_console(&uart->port))
uart->port.cons->flags &= ~CON_PRINTBUFFER;
uart_remove_one_port(&serial8250_reg, &uart->port);
}
uart->port.ctrl_id = up->port.ctrl_id;
uart->port.port_id = up->port.port_id;