[PATCH 1/1] early_printk: Protect against using the same device twice

From: Jason Wessel
Date: Wed Sep 23 2009 - 18:34:42 EST


If you use the kernel argument:

earlyprintk=serial,ttyS0,115200

This will cause a recursive crash. Instead warn the end user that they
specified the device a second time.

Signed-off-by: Jason Wessel <jason.wessel@xxxxxxxxxxxxx>
---
arch/x86/kernel/early_printk.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
index 2acfd3f..712661a 100644
--- a/arch/x86/kernel/early_printk.c
+++ b/arch/x86/kernel/early_printk.c
@@ -178,11 +178,19 @@ asmlinkage void early_printk(const char *fmt, ...)

static inline void early_console_register(struct console *con, int keep_early)
{
+ struct console *bcon;
+
early_console = con;
if (keep_early)
early_console->flags &= ~CON_BOOT;
else
early_console->flags |= CON_BOOT;
+ for (bcon = console_drivers; bcon != NULL; con = bcon->next)
+ if (strcmp(bcon->name, con->name) == 0) {
+ printk(KERN_CRIT "ERROR: earlyprintk= %s console"
+ " already defined\n", con->name);
+ return;
+ }
register_console(early_console);
}

--
1.6.3.1.9.g95405b


--------------020208090807060007050900--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/