aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/printk
diff options
context:
space:
mode:
authorJohn Ogness <john.ogness@linutronix.de>2024-09-04 14:11:22 +0206
committerPetr Mladek <pmladek@suse.com>2024-09-04 15:56:32 +0200
commit0e53e2d9f72080b7ea1a4003558041fee78cdef9 (patch)
tree53a1aaeaba76dd74a28ba2aee08822ed3f3e4dfa /kernel/printk
parentprintk: Fail pr_flush() if before SYSTEM_SCHEDULING (diff)
downloadlinux-rng-0e53e2d9f72080b7ea1a4003558041fee78cdef9.tar.xz
linux-rng-0e53e2d9f72080b7ea1a4003558041fee78cdef9.zip
printk: Flush console on unregister_console()
Ensure consoles have flushed pending records before unregistering. The console should print up to at least its related "console disabled" record. Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20240904120536.115780-4-john.ogness@linutronix.de Signed-off-by: Petr Mladek <pmladek@suse.com>
Diffstat (limited to 'kernel/printk')
-rw-r--r--kernel/printk/printk.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index acf668001096..c79e962b822a 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3771,11 +3771,16 @@ static int unregister_console_locked(struct console *console)
if (res > 0)
return 0;
+ if (!console_is_registered_locked(console))
+ res = -ENODEV;
+ else if (console_is_usable(console, console->flags))
+ __pr_flush(console, 1000, true);
+
/* Disable it unconditionally */
console_srcu_write_flags(console, console->flags & ~CON_ENABLED);
- if (!console_is_registered_locked(console))
- return -ENODEV;
+ if (res < 0)
+ return res;
/*
* Use the driver synchronization to ensure that the hardware is not