Skip to content

Commit

Permalink
tty: serial: kgdboc: use console_list_lock to trap exit
Browse files Browse the repository at this point in the history
kgdboc_earlycon_init() uses the console_lock to ensure that no consoles
are unregistered until the kgdboc_earlycon is setup. The console_list_lock
should be used instead because list synchronization responsibility will
be removed from the console_lock in a later change.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20221116162152.193147-39-john.ogness@linutronix.de
  • Loading branch information
John Ogness authored and Petr Mladek committed Dec 2, 2022
1 parent 6193bc9 commit e2b3965
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/tty/serial/kgdboc.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,13 +558,13 @@ static int __init kgdboc_earlycon_init(char *opt)
*/

/*
* Hold the console_lock to guarantee that no consoles are
* Hold the console_list_lock to guarantee that no consoles are
* unregistered until the kgdboc_earlycon setup is complete.
* Trapping the exit() callback relies on exit() not being
* called until the trap is setup. This also allows safe
* traversal of the console list and race-free reading of @flags.
*/
console_lock();
console_list_lock();
for_each_console(con) {
if (con->write && con->read &&
(con->flags & (CON_BOOT | CON_ENABLED)) &&
Expand Down Expand Up @@ -606,7 +606,7 @@ static int __init kgdboc_earlycon_init(char *opt)
}

unlock:
console_unlock();
console_list_unlock();

/* Non-zero means malformed option so we always return zero */
return 0;
Expand Down

0 comments on commit e2b3965

Please sign in to comment.