[PATCH] Fix crash in unregister_console()

If unregister_console() is inadvertently called while no consoles are
registered, it will crash trying to dereference NULL pointer. It is
necessary to fix that because register_console() provides no indication
that it actually registered the console passed in. In fact, it may well
decide not to register it based on various things...

(akpm: It'd be better to make register_console() return something and fix the
callers. All 106 of them...)

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Benjamin Herrenschmidt and committed by Linus Torvalds e9b15b54 962b564c

+1 -1
+1 -1
kernel/printk.c
··· 956 956 if (console_drivers == console) { 957 957 console_drivers=console->next; 958 958 res = 0; 959 - } else { 959 + } else if (console_drivers) { 960 960 for (a=console_drivers->next, b=console_drivers ; 961 961 a; b=a, a=b->next) { 962 962 if (a == console) {