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

From: Petr Mladek

Date: Tue Sep 29 2026 - 08:10:06 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>
---
drivers/accessibility/braille/braille_console.c | 10 +++++-----
include/linux/console.h | 1 +
kernel/printk/printk.c | 2 +-
3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/accessibility/braille/braille_console.c b/drivers/accessibility/braille/braille_console.c
index 7e6011f9d823..200ca305c6af 100644
--- a/drivers/accessibility/braille/braille_console.c
+++ b/drivers/accessibility/braille/braille_console.c
@@ -389,11 +389,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 d780f6de303a..11d6b854ee63 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -699,6 +699,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 683083405230..f2a602a05614 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3948,7 +3948,7 @@ 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)
+int console_call_setup(struct console *newcon, char *options)
{
int err;

--
2.55.0