@@ -193,7 +193,16 @@ static int configure_kgdboc(void)
if (!p)
goto noconfig;
+ /* For safe traversal of the console list. */
+ console_list_lock();
+
+ /*
+ * Take console_lock to serialize device() callback with
+ * other console operations. For example, fg_console is
+ * modified under console_lock when switching vt.
+ */
console_lock();
+
for_each_console(cons) {
int idx;
if (cons->device && cons->device(cons, &idx) == p &&
@@ -202,8 +211,11 @@ static int configure_kgdboc(void)
break;
}
}
+
console_unlock();
+ console_list_unlock();
+
kgdb_tty_driver = p;
kgdb_tty_line = tty_line;