On 2023-09-21, Lukas Wunner <lukas@xxxxxxxxx> wrote: > diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c > index 7bdc21d5e13b..ca26a8aef2cb 100644 > --- a/drivers/tty/serial/serial_core.c > +++ b/drivers/tty/serial/serial_core.c > @@ -1404,12 +1404,18 @@ static void uart_set_rs485_termination(struct uart_port *port, > static int uart_rs485_config(struct uart_port *port) > { > struct serial_rs485 *rs485 = &port->rs485; > + unsigned long flags; > int ret; > > + if (!(rs485->flags & SER_RS485_ENABLED)) > + return 0; > + > uart_sanitize_serial_rs485(port, rs485); > uart_set_rs485_termination(port, rs485); > > + spin_lock_irqsave(&port->lock, flags); > ret = port->rs485_config(port, NULL, rs485); > + spin_unlock_irqrestore(&port->lock, flags); > if (ret) > memset(rs485, 0, sizeof(*rs485)); Is there some kind of guarantee that 2 CPUs cannot go into uart_rs485_config() simultaneously? Otherwise it seems dangerous to be using and clearing @port->rs485 outside of the spin_lock. John Ogness