kernel/printk/nbcon.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
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>
---
I found this issue while creating a custom kernel module that implements
the nbcon interfaces.
---
Changes in v2:
- Merged the checks device locks with write_thread check, suggested by John.
- Link to v1: https://patch.msgid.link/20251205-nbcon-device-cb-fix-v1-1-906bdff5760b@suse.com
---
kernel/printk/nbcon.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
index 3fa403f9831f..1dfc4a6a44bf 100644
--- a/kernel/printk/nbcon.c
+++ b/kernel/printk/nbcon.c
@@ -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);
---
base-commit: 322530a9c2ab1da67e5b0988fa29aca64d96ec8f
change-id: 20251205-nbcon-device-cb-fix-7ce745a21ba8
Best regards,
--
Marcos Paulo de Souza <mpdesouza@suse.com>
On Mon 2025-12-08 11:06:16, Marcos Paulo de Souza wrote: > 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> JFYI, the patch has been pushed into printk/linux.git, branch for-6.20. Best Regards, Petr
On 2025-12-08, Marcos Paulo de Souza <mpdesouza@suse.com> wrote: > 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> > --- > I found this issue while creating a custom kernel module that implements > the nbcon interfaces. > --- > Changes in v2: > - Merged the checks device locks with write_thread check, suggested by John. > - Link to v1: https://patch.msgid.link/20251205-nbcon-device-cb-fix-v1-1-906bdff5760b@suse.com > --- Thanks! Reviewed-by: John Ogness <john.ogness@linutronix.de>
© 2016 - 2025 Red Hat, Inc.