[tip: sched/rt] printk: Flush console on unregister_console()
From: tip-bot2 for John Ogness
Date: Mon Sep 09 2024 - 13:30:06 EST
The following commit has been merged into the sched/rt branch of tip:
Commit-ID: 0e53e2d9f72080b7ea1a4003558041fee78cdef9
Gitweb: https://git.kernel.org/tip/0e53e2d9f72080b7ea1a4003558041fee78cdef9
Author: John Ogness <john.ogness@xxxxxxxxxxxxx>
AuthorDate: Wed, 04 Sep 2024 14:11:22 +02:06
Committer: Petr Mladek <pmladek@xxxxxxxx>
CommitterDate: Wed, 04 Sep 2024 15:56:32 +02:00
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@xxxxxxxxxxxxx>
Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>
Link: https://lore.kernel.org/r/20240904120536.115780-4-john.ogness@xxxxxxxxxxxxx
Signed-off-by: Petr Mladek <pmladek@xxxxxxxx>
---
kernel/printk/printk.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index acf6680..c79e962 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