Skip to content

Commit 0e53e2d

Browse files
jognesspmladek
authored andcommitted
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 <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Petr Mladek <[email protected]>
1 parent e37577e commit 0e53e2d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

kernel/printk/printk.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3771,11 +3771,16 @@ static int unregister_console_locked(struct console *console)
37713771
if (res > 0)
37723772
return 0;
37733773

3774+
if (!console_is_registered_locked(console))
3775+
res = -ENODEV;
3776+
else if (console_is_usable(console, console->flags))
3777+
__pr_flush(console, 1000, true);
3778+
37743779
/* Disable it unconditionally */
37753780
console_srcu_write_flags(console, console->flags & ~CON_ENABLED);
37763781

3777-
if (!console_is_registered_locked(console))
3778-
return -ENODEV;
3782+
if (res < 0)
3783+
return res;
37793784

37803785
/*
37813786
* Use the driver synchronization to ensure that the hardware is not

0 commit comments

Comments
 (0)