Re: [PATCH/RFC] tty: serial_core: Move uart_console() check after console registration

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

 



Hi Rob,

On Mon, Oct 3, 2016 at 8:25 PM, Rob Herring <robh@xxxxxxxxxx> wrote:
> On Thu, Sep 29, 2016 at 10:31 AM, Geert Uytterhoeven
> <geert+renesas@xxxxxxxxx> 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?

Isn't .index always initialized to -1, and set to the actual line number when
the console is registered? That's how I remember it from when
register_console() was introduced (in 2.1)...

>> 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 <niklas.soderlund+renesas@xxxxxxxxxxxx>
>> Reported-by: Takeshi Kihara <takeshi.kihara.df@xxxxxxxxxxx>
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
>> ---
>> 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.

Shouldn't a double initialization cause a warning, with DEBUG_SPINLOCK=y
(which I have enabled)?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds




[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux