Re: [PATCH 1/2] tty: serial: 8250: always call tx_chars under spinlock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 09, 2020 at 10:17:27AM +0100, Steffen Trumtrar wrote:
> In most cases serial8250_tx_chars is called with spinlock held.
> Fix the remaining location, too.

Please explain where __start_tx() is called without holding the port
lock and consider fixing that up.

> Signed-off-by: Steffen Trumtrar <s.trumtrar@xxxxxxxxxxxxxx>
> ---
>  drivers/tty/serial/8250/8250_port.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
> index b0af13074cd3..3310c2b70138 100644
> --- a/drivers/tty/serial/8250/8250_port.c
> +++ b/drivers/tty/serial/8250/8250_port.c
> @@ -1559,6 +1559,7 @@ static void serial8250_stop_tx(struct uart_port *port)
>  static inline void __start_tx(struct uart_port *port)
>  {
>  	struct uart_8250_port *up = up_to_u8250p(port);
> +	unsigned long flags;
>  
>  	if (up->dma && !up->dma->tx_dma(up))
>  		return;
> @@ -1569,8 +1570,11 @@ static inline void __start_tx(struct uart_port *port)
>  
>  			lsr = serial_in(up, UART_LSR);
>  			up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;
> -			if (lsr & UART_LSR_THRE)
> +			if (lsr & UART_LSR_THRE) {
> +				spin_lock_irqsave(&port->lock, flags);
>  				serial8250_tx_chars(up);
> +				spin_unlock_irqrestore(&port->lock, flags);
> +			}

Since several callers of __start_tx() do hold the lock, this change will
introduce a deadlock.

>  		}
>  	}

Johan



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux