Skip to content

Commit 6685744

Browse files
jognesspmladek
authored andcommitted
tty: serial: kgdboc: use console_list_lock for list traversal
configure_kgdboc() uses the console_lock for console list iteration. Use the console_list_lock instead because list synchronization responsibility will be removed from the console_lock in a later change. The SRCU iterator could have been used here, but a later change will relocate the locking of the console_list_lock to also provide synchronization against register_console(). Note, the console_lock is still needed to serialize the device() callback with other console operations. Signed-off-by: John Ogness <[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 7e537af commit 6685744

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/tty/serial/kgdboc.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,16 @@ static int configure_kgdboc(void)
193193
if (!p)
194194
goto noconfig;
195195

196+
/* For safe traversal of the console list. */
197+
console_list_lock();
198+
199+
/*
200+
* Take console_lock to serialize device() callback with
201+
* other console operations. For example, fg_console is
202+
* modified under console_lock when switching vt.
203+
*/
196204
console_lock();
205+
197206
for_each_console(cons) {
198207
int idx;
199208
if (cons->device && cons->device(cons, &idx) == p &&
@@ -202,8 +211,11 @@ static int configure_kgdboc(void)
202211
break;
203212
}
204213
}
214+
205215
console_unlock();
206216

217+
console_list_unlock();
218+
207219
kgdb_tty_driver = p;
208220
kgdb_tty_line = tty_line;
209221

0 commit comments

Comments
 (0)