Fwd: [PATCH] kdb: Avoid using dbg_io_ops until it is initialized

From: Tim Bird
Date: Tue Mar 20 2012 - 12:34:29 EST


Jason,

This patch has apparently fallen through the cracks. Can you please apply?
This fixes a kernel panic for a use case where I'm setting a breakpoint
from kdb_cmds on kernel startup. In this case, without this patch
dbg_io_ops is used before it is initialized.

Thanks,
-- Tim

-------- Original Message --------
Subject: [PATCH] kdb: Avoid using dbg_io_ops until it is initialized
Date: Wed, 21 Sep 2011 13:19:12 -0700
From: Tim Bird <tim.bird@xxxxxxxxxxx>
To: Jason Wessel <jason.wessel@xxxxxxxxxxxxx>
CC: kgdb-bugreport@xxxxxxxxxxxxxxxxxxxxx <kgdb-bugreport@xxxxxxxxxxxxxxxxxxxxx>, linux kernel <linux-kernel@xxxxxxxxxxxxxxx>

This fixes a bug with setting a breakpoint during kdb initialization
(from kdb_cmds). Any call to kdb_printf() before the initialization
of the kgdboc serial console driver (which happens much later in
bootup than kdb_init), results in kernel panic due to the use of
dbg_io_ops before it is initialized.

Signed-off-by: Tim Bird <tim.bird@xxxxxxxxxxx>
---
kernel/debug/kdb/kdb_io.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index c9b7f4f..3bc995f 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -675,7 +675,7 @@ kdb_printit:
if (!dbg_kdb_mode && kgdb_connected) {
gdbstub_msg_write(kdb_buffer, retlen);
} else {
- if (!dbg_io_ops->is_console) {
+ if (dbg_io_ops && !dbg_io_ops->is_console) {
len = strlen(kdb_buffer);
cp = kdb_buffer;
while (len--) {
--
1.7.2.3



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