Skip to content

Commit 6193bc9

Browse files
jognesspmladek
authored andcommitted
tty: serial: kgdboc: synchronize tty_find_polling_driver() and register_console()
Calling tty_find_polling_driver() can lead to uart_set_options() being called (via the poll_init() callback of tty_operations) to configure the uart. But uart_set_options() can also be called by register_console() (via the setup() callback of console). Take the console_list_lock to synchronize against register_console() and also use it for console list traversal. This also ensures the console list cannot change until the polling console has been chosen. Signed-off-by: John Ogness <[email protected]> Reviewed-by: Daniel Thompson <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Reviewed-by: Douglas Anderson <[email protected]> Signed-off-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 6685744 commit 6193bc9

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

drivers/tty/serial/kgdboc.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,20 @@ static int configure_kgdboc(void)
189189
if (kgdboc_register_kbd(&cptr))
190190
goto do_register;
191191

192+
/*
193+
* tty_find_polling_driver() can call uart_set_options()
194+
* (via poll_init) to configure the uart. Take the console_list_lock
195+
* in order to synchronize against register_console(), which can also
196+
* configure the uart via uart_set_options(). This also allows safe
197+
* traversal of the console list.
198+
*/
199+
console_list_lock();
200+
192201
p = tty_find_polling_driver(cptr, &tty_line);
193-
if (!p)
202+
if (!p) {
203+
console_list_unlock();
194204
goto noconfig;
195-
196-
/* For safe traversal of the console list. */
197-
console_list_lock();
205+
}
198206

199207
/*
200208
* Take console_lock to serialize device() callback with

0 commit comments

Comments
 (0)