diff options
author | Tony Lindgren <tony@atomide.com> | 2024-03-27 13:59:37 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-04-09 16:30:13 +0300 |
commit | b73c9cbe4f1fc02645228aa575998dd54067f8ef (patch) | |
tree | 78744490609a7ca67b8432344b5059372e35f700 /kernel/printk/printk.c | |
parent | 8a831c584e6e80cf68f79893dc395c16cdf47dc8 (diff) | |
download | linux-b73c9cbe4f1fc02645228aa575998dd54067f8ef.tar.xz |
printk: Flag register_console() if console is set on command line
If add_preferred_console() is not called early in setup_console(), we can
end up having register_console() call try_enable_default_console() before a
console device has called add_preferred_console().
Let's set console_set_on_cmdline flag in console_setup() to prevent this
from happening.
Signed-off-by: Tony Lindgren <tony@atomide.com>
Link: https://lore.kernel.org/r/20240327110021.59793-4-tony@atomide.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel/printk/printk.c')
-rw-r--r-- | kernel/printk/printk.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 67937e5c6010..1e3b21682547 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2504,6 +2504,9 @@ static int __init console_setup(char *str) if (console_opt_save(str, brl_options)) return 1; + /* Flag register_console() to not call try_enable_default_console() */ + console_set_on_cmdline = 1; + /* Don't attempt to parse a DEVNAME:0.0 style console */ if (strchr(str, ':')) return 1; @@ -3507,7 +3510,7 @@ void register_console(struct console *newcon) * Note that a console with tty binding will have CON_CONSDEV * flag set and will be first in the list. */ - if (preferred_console < 0) { + if (preferred_console < 0 && !console_set_on_cmdline) { if (hlist_empty(&console_list) || !console_first()->device || console_first()->flags & CON_BOOT) { try_enable_default_console(newcon); |