[PATCH v6 11/16] console/braille: Lock console->setup() call during the registration

From: Petr Mladek

Date: Fri Nov 06 2026 - 12:30:08 EST


In braille_register_console(), the console->setup() callback must be
called while holding the console_lock. This prevents a race condition
with a possible active boot console that might be using the same hardware
registers.

See also the commit 801410b26a0e ("serial: Lock console when calling into
driver before registration").

Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
Closes: https://sashiko.dev/#/patchset/20260423130015.85175-1-pmladek%40suse.com
Suggested-by: John Ogness <john.ogness@xxxxxxxxxxxxx>
Signed-off-by: Petr Mladek <pmladek@xxxxxxxx>
Acked-by: Chris Down <chris@xxxxxxxxxxxxxx>
---
drivers/accessibility/braille/braille_console.c | 10 +++++-----
include/linux/console.h | 1 +
kernel/printk/printk.c | 8 +++++++-
3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/accessibility/braille/braille_console.c b/drivers/accessibility/braille/braille_console.c
index 1b79b4d88bac..bc338e57d8ef 100644
--- a/drivers/accessibility/braille/braille_console.c
+++ b/drivers/accessibility/braille/braille_console.c
@@ -408,11 +408,11 @@ int braille_register_console(struct console *console, int index,
console_options = "57600o8";
if (braille_co)
return -ENODEV;
- if (console->setup) {
- ret = console->setup(console, console_options);
- if (ret != 0)
- return ret;
- }
+
+ ret = console_call_setup(console, console_options);
+ if (ret != 0)
+ return ret;
+
console->flags |= CON_ENABLED | CON_BRL;
console->index = index;
braille_co = console;
diff --git a/include/linux/console.h b/include/linux/console.h
index cb8be9ea4a76..b68279a22514 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -710,6 +710,7 @@ enum con_flush_mode {
};

extern int add_preferred_console(const char *name, const short idx, char *options);
+extern int console_call_setup(struct console *newcon, char *options);
extern void console_force_preferred_locked(struct console *con);
extern void register_console(struct console *);
extern int unregister_console(struct console *);
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 49c5624eede0..0e68af9a3490 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3957,7 +3957,13 @@ static int __init keep_bootcon_setup(char *str)

early_param("keep_bootcon", keep_bootcon_setup);

-static int console_call_setup(struct console *newcon, char *options)
+/*
+ * The function is intended only for the generic console registration code.
+ * It has been made global only for the Braille console driver which
+ * is partly using the generic console registration code but it is
+ * integrated with VT code instead of printk().
+ */
+int console_call_setup(struct console *newcon, char *options)
{
int err;

--
2.56.0