Subject: [PATCH 01/24] kdb: do not assume write() callback available
From: John Ogness <[email-masked]>
Date: Fri, 24 Feb 2023 15:23:51 +0000

It is allowed for consoles to provide no write() callback. For
example ttynull does this.

Check if a write() callback is available before using it.

Signed-off-by: John Ogness <[email-masked]>
Signed-off-by: Sebastian Andrzej Siewior <[email-masked]>
---
 kernel/debug/kdb/kdb_io.c |    2 ++
 1 file changed, 2 insertions(+)

Index: linux-6.3.0-rt11/kernel/debug/kdb/kdb_io.c
===================================================================
--- linux-6.3.0-rt11.orig/kernel/debug/kdb/kdb_io.c
+++ linux-6.3.0-rt11/kernel/debug/kdb/kdb_io.c
@@ -576,6 +576,8 @@ static void kdb_msg_write(const char *ms
 			continue;
 		if (c == dbg_io_ops->cons)
 			continue;
+		if (!c->write)
+			continue;
 		/*
 		 * Set oops_in_progress to encourage the console drivers to
 		 * disregard their internal spin locks: in the current calling