Re: [PATCH] - printk handling more than one CON_BOOT

From: Robin Getz
Date: Tue Jul 21 2009 - 14:33:44 EST


On Wed 1 Jul 2009 21:08, Robin Getz pondered:
> printk.c | 146 +++++++++++++++++++++++++++++++++--------------------
> 1 file changed, 92 insertions(+), 54 deletions(-)
>
> diff --git a/kernel/printk.c b/kernel/printk.c
> index b4d97b5..9acc262 100644
> --- a/kernel/printk.c
> +++ b/kernel/printk.c

[snip]

> static int __init disable_boot_consoles(void)
> {
> - if (console_drivers != NULL) {
> - if (console_drivers->flags & CON_BOOT) {
> + struct console *con;
> +
> + for_each_console(con) {
> + if (con->flags & CON_BOOT) {
> printk(KERN_INFO "turn off boot console %s%d\n",
> - console_drivers->name, console_drivers->index);
> - return unregister_console(console_drivers);
> + con->name, con->index);
> + return unregister_console(con);
> }
> }
> return 0;

This causes a bug that Sonic found.

The below patch fixes it, and should be applied to tip.

---

From: Sonic Zhang <Sonic.Zhang@xxxxxxxxxx>

Don't return when we find the first bootconsole - it can leave other
bootconsoles still installed, and they can be used and cause problems later
(if they are in the init section, and eventually released), and cause
problems. Make sure we remove all of them.

Signed-off-by: Sonic Zhang <Sonic.Zhang@xxxxxxxxxx>
Signed-off-by: Robin Getz <rgetz@xxxxxxxxxx>

---

diff --git a/kernel/printk.c b/kernel/printk.c
index e0daaf5..e10d193 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1352,7 +1352,7 @@ static int __init disable_boot_consoles(void)
if (con->flags & CON_BOOT) {
printk(KERN_INFO "turn off boot console %s%d\n",
con->name, con->index);
- return unregister_console(con);
+ unregister_console(con);
}
}
return 0;

--
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/