]> git.baikalelectronics.ru Git - kernel.git/commit
init/console: Use ttynull as a fallback when there is no console
authorPetr Mladek <pmladek@suse.com>
Wed, 11 Nov 2020 13:54:49 +0000 (14:54 +0100)
committerPetr Mladek <pmladek@suse.com>
Fri, 20 Nov 2020 11:23:50 +0000 (12:23 +0100)
commit4cd3cf5e470759479be0c8844813d1f2a36423f9
treef7cd4581dd54753277acbe1822277ed98743ed55
parent03d23a79e0d450c2f3a4f227cce830d6233d4811
init/console: Use ttynull as a fallback when there is no console

stdin, stdout, and stderr standard I/O stream are created for the init
process. They are not available when there is no console registered
for /dev/console. It might lead to a crash when the init process
tries to use them, see the commit 7875f8ad1c571236ce8 ("printk: handle
blank console arguments passed in.").

Normally, ttySX and ttyX consoles are used as a fallback when no consoles
are defined via the command line, device tree, or SPCR. But there
will be no console registered when an invalid console name is configured
or when the configured consoles do not exist on the system.

Users even try to avoid the console intentionally, for example,
by using console="" or console=null. It is used on production
systems where the serial port or terminal are not visible to
users. Pushing messages to these consoles would just unnecessary
slowdown the system.

Make sure that stdin, stdout, stderr, and /dev/console are always
available by a fallback to the existing ttynull driver. It has
been implemented for exactly this purpose but it was used only
when explicitly configured.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20201111135450.11214-2-pmladek@suse.com
drivers/tty/Kconfig
drivers/tty/Makefile
drivers/tty/ttynull.c
include/linux/console.h
init/main.c