From: Thomas Gleixner Date: Wed, 16 Nov 2022 16:21:13 +0000 (+0106) Subject: serial: kgdboc: Lock console list in probe function X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=9e409c4778afbbd44759e56ec4bbed839fd31909;p=linux.git serial: kgdboc: Lock console list in probe function Unprotected list walks are not necessarily safe. Signed-off-by: Thomas Gleixner Signed-off-by: John Ogness Reviewed-by: Greg Kroah-Hartman Reviewed-by: Douglas Anderson Reviewed-by: Sergey Senozhatsky Reviewed-by: Petr Mladek Reviewed-by: Daniel Thompson Signed-off-by: Petr Mladek Link: https://lore.kernel.org/r/20221116162152.193147-2-john.ogness@linutronix.de --- diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c index 7aa37be3216a5..e76f0186c3355 100644 --- 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;