fix - ensure we don't use bootconsoles after init has been released
authorRobin Getz <rgetz@blackfin.uclinux.org>
Wed, 22 Aug 2007 03:14:58 +0000 (23:14 -0400)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Wed, 22 Aug 2007 03:23:53 +0000 (20:23 -0700)
Gerd Hoffmann pointed out that my patch from yesterday can lead
to a null pointer dereference if the kernel is booted with no
console, and no earlyprintk defined. This fixes that issue.

Signed-off-by: Robin Getz <rgetz@blackfin.uclinux.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/printk.c

index 5c7c325b29cc9ddc5e3f6cee6cfa73074ebacdbe..8451dfc31d25b4e0e6903e84a55de230fb5363e2 100644 (file)
@@ -1085,10 +1085,12 @@ EXPORT_SYMBOL(unregister_console);
 
 static int __init disable_boot_consoles(void)
 {
-       if (console_drivers->flags & CON_BOOT) {
-               printk(KERN_INFO "turn off boot console %s%d\n",
-                       console_drivers->name, console_drivers->index);
-               return unregister_console(console_drivers);
+       if (console_drivers != NULL) {
+               if (console_drivers->flags & CON_BOOT) {
+                       printk(KERN_INFO "turn off boot console %s%d\n",
+                               console_drivers->name, console_drivers->index);
+                       return unregister_console(console_drivers);
+               }
        }
        return 0;
 }