Re: [PATCH] tty: serial_core: Clear TTY_IO_ERROR if tty_port_open() return 0

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

 



On Sun, Nov 20, 2016 at 9:31 PM, Huacai Chen <chenhc@xxxxxxxxxx> wrote:
> After commit b3b57646186400d4f ("tty: serial_core: convert uart_open
> to use tty_port_open") and 761ed4a94582ab291a ("tty: serial_core:
> convert uart_close to use tty_port_close"), TTY_IO_ERROR is set by
> tty_port_close() unconditionally, but cleared by tty_port_open() only
> when tty_port_initialized() return 0.
>
> This is a bug: If we use "console=ttyS*" in kernel parameters, the
> corresponding serial port's port->console will be true. When somebody
> close the serial port, tty_port_close() will return without calling
> tty_port_set_initialized(port, 0). Then, when it is opened again,
> tty_port_open() will not clear TTY_IO_ERROR, and serial port becomes
> unavailable at last.
>
> So, this patch clear TTY_IO_ERROR in uart_open() if tty_port_open()
> return 0.

This seems like a bug in tty_port code to me. I think TTY_IO_ERROR
should not get set if the port is a console. Alan? Peter?

Rob

>
> Signed-off-by: Ce Sun <sunc@xxxxxxxxxx>
> Signed-off-by: Huacai Chen <chenhc@xxxxxxxxxx>
> ---
>  drivers/tty/serial/serial_core.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index f2303f3..58be3ef 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -1690,6 +1690,8 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
>         tty->driver_data = state;
>
>         retval = tty_port_open(&state->port, tty, filp);
> +       if (!retval)
> +               clear_bit(TTY_IO_ERROR, &tty->flags);
>         if (retval > 0)
>                 retval = 0;
>
> --
> 2.7.0
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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