pstore: Make sure console capturing will restart
authorKees Cook <keescook@chromium.org>
Wed, 6 May 2020 23:34:42 +0000 (16:34 -0700)
committerKees Cook <keescook@chromium.org>
Sat, 30 May 2020 17:34:02 +0000 (10:34 -0700)
The CON_ENABLED flag gets cleared during unregister_console(), so make
sure we already reset the console flags before calling register_console(),
otherwise unloading and reloading a pstore backend will not restart
console logging.

Signed-off-by: Kees Cook <keescook@chromium.org>
fs/pstore/platform.c

index 398785a..8beaeff 100644 (file)
@@ -516,12 +516,16 @@ static void pstore_console_write(struct console *con, const char *s, unsigned c)
 static struct console pstore_console = {
        .name   = "pstore",
        .write  = pstore_console_write,
-       .flags  = CON_PRINTBUFFER | CON_ENABLED | CON_ANYTIME,
        .index  = -1,
 };
 
 static void pstore_register_console(void)
 {
+       /*
+        * Always initialize flags here since prior unregister_console()
+        * calls may have changed settings (specifically CON_ENABLED).
+        */
+       pstore_console.flags = CON_PRINTBUFFER | CON_ENABLED | CON_ANYTIME;
        register_console(&pstore_console);
 }