On Thu, Sep 29, 2016 at 10:31 AM, Geert Uytterhoeven
<[email protected]> wrote:
> The port->console flag is always false, as uart_console() is called
> before the serial console has been registered.

I'm not seeing how that is. Everything uart_console() depends on
(port->cons, port->cons->index, and port->line) should be set already.
Maybe you pass in -1 for index which gets changed to 0 is the only
thing I can see. Is doing that valid if you have multiple ports?

> Hence for a serial port used as the console, uart_tty_port_shutdown()
> will still be called when userspace closes the port, powering it down.
> This will lead to a system lock up when the serial console driver writes
> to the serial port's registers.
>
> To fix this, move the setting of port->console after the call to
> uart_configure_port(), which registers the serial console.
>
> Fixes: 761ed4a94582ab29 ("tty: serial_core: convert uart_close to use 
> tty_port_close")
> Reported-by: Niklas Söderlund <[email protected]>
> Reported-by: Takeshi Kihara <[email protected]>
> Signed-off-by: Geert Uytterhoeven <[email protected]>
> ---
> RFC because of the comment "If this port is a console, then the spinlock
> is already initialised", and the pre-existing code calling
> uart_console() before uart_configure_port().

So the spinlock is initialized twice which is probably harmless? If
the spinlock was initialized by the console, then the index would
probably not be -1.

Rob

Reply via email to