aboutsummaryrefslogtreecommitdiff
path: root/drivers/tty
diff options
context:
space:
mode:
authorJohn Ogness2022-11-16 17:27:20 +0106
committerPetr Mladek2022-12-02 11:25:00 +0100
commit0fb413ea64603a71e19b4b15a6c5b704e3897d06 (patch)
treeddf789a84cf447301b08bab6c1842e69c87d9666 /drivers/tty
parent3860e7c57fd23e744e045436f9872fb9d01381e2 (diff)
tty: serial: kgdboc: document console_lock usage
kgdboc_earlycon_init() uses the console_lock to ensure that no consoles are unregistered until the kgdboc_earlycon is setup. This is necessary because the trapping of the exit() callback assumes that the exit() callback is not called before the trap is setup. Explicitly document this non-typical console_lock usage. Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Douglas Anderson <dianders@chromium.org> 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-9-john.ogness@linutronix.de
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/kgdboc.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
index e76f0186c335..5be381003e58 100644
--- a/drivers/tty/serial/kgdboc.c
+++ b/drivers/tty/serial/kgdboc.c
@@ -530,6 +530,14 @@ static int __init kgdboc_earlycon_init(char *opt)
* Look for a matching console, or if the name was left blank just
* pick the first one we find.
*/
+
+ /*
+ * Hold the console_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();
for_each_console(con) {
if (con->write && con->read &&