]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
printk: nbcon: Check for device_{lock,unlock} callbacks
authorMarcos Paulo de Souza <mpdesouza@suse.com>
Mon, 8 Dec 2025 14:06:16 +0000 (11:06 -0300)
committerPetr Mladek <pmladek@suse.com>
Mon, 15 Dec 2025 14:10:33 +0000 (15:10 +0100)
These callbacks are necessary to synchronize ->write_thread callback
against other operations using the same device.

Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
Reviewed-by: John Ogness <john.ogness@linutronix.de>
Link: https://patch.msgid.link/20251208-nbcon-device-cb-fix-v2-1-36be8d195123@suse.com
Signed-off-by: Petr Mladek <pmladek@suse.com>
kernel/printk/nbcon.c

index 3fa403f9831f044fa88292c87ba06f43ade186e1..1dfc4a6a44bf469751d2fc16c748f24e8f85bfa6 100644 (file)
@@ -1760,9 +1760,12 @@ bool nbcon_alloc(struct console *con)
        /* Synchronize the kthread start. */
        lockdep_assert_console_list_lock_held();
 
-       /* The write_thread() callback is mandatory. */
-       if (WARN_ON(!con->write_thread))
+       /* Check for mandatory nbcon callbacks. */
+       if (WARN_ON(!con->write_thread ||
+                   !con->device_lock ||
+                   !con->device_unlock)) {
                return false;
+       }
 
        rcuwait_init(&con->rcuwait);
        init_irq_work(&con->irq_work, nbcon_irq_work);