Commit bdfcca65 authored by Marcos Paulo de Souza's avatar Marcos Paulo de Souza Committed by Petr Mladek
Browse files

printk: nbcon: Check for device_{lock,unlock} callbacks



These callbacks are necessary to synchronize ->write_thread callback
against other operations using the same device.

Signed-off-by: default avatarMarcos Paulo de Souza <mpdesouza@suse.com>
Reviewed-by: default avatarJohn Ogness <john.ogness@linutronix.de>
Link: https://patch.msgid.link/20251208-nbcon-device-cb-fix-v2-1-36be8d195123@suse.com


Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
parent 4d38b88f
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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);