Skip to content

Commit

Permalink
tty: serial: kgdboc: use console_list_lock for list traversal
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
jogness authored and pmladek committed Dec 2, 2022
1 parent 7e537af commit 6685744
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/tty/serial/kgdboc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand All @@ -202,8 +211,11 @@ static int configure_kgdboc(void)
break;
}
}

console_unlock();

console_list_unlock();

kgdb_tty_driver = p;
kgdb_tty_line = tty_line;

Expand Down

0 comments on commit 6685744

Please sign in to comment.