[patch RFC 09/29] serial: kgdboc: Lock consoles in probe function

From: Thomas Gleixner
Date: Sat Sep 10 2022 - 18:28:38 EST


Unprotected list walks are not necessarily safe.

Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
---
drivers/tty/serial/kgdboc.c | 2 ++
1 file changed, 2 insertions(+)

--- a/drivers/tty/serial/kgdboc.c
+++ b/drivers/tty/serial/kgdboc.c
@@ -193,6 +193,7 @@ static int configure_kgdboc(void)
if (!p)
goto noconfig;

+ console_lock();
for_each_console(cons) {
int idx;
if (cons->device && cons->device(cons, &idx) == p &&
@@ -201,6 +202,7 @@ static int configure_kgdboc(void)
break;
}
}
+ console_unlock();

kgdb_tty_driver = p;
kgdb_tty_line = tty_line;