[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230214115921.399608-1-michael.thalmeier@hale.at>
Date: Tue, 14 Feb 2023 12:59:21 +0100
From: Michael Thalmeier <michael.thalmeier@...e.at>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jirislaby@...nel.org>,
Vincent Whitchurch <vincent.whitchurch@...s.com>
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH v2] tty: ttynull: implement console write
Since commit a699449bb13b ("printk: refactor and rework printing logic"),
con->write is called without checking if it is implemented in the console
driver. This does make some sense, because for all "normal" consoles it
is vital to have a write function.
As the ttynull console driver does not need any console output the write
function was not implemented. This caused a "unable to handle kernel NULL
pointer dereference" when the write function is called now.
To fix this issue, implement an empty write function.
Fixes: a699449bb13b ("printk: refactor and rework printing logic")
Cc: stable@...r.kernel.org
Signed-off-by: Michael Thalmeier <michael.thalmeier@...e.at>
---
Changes in v2:
- Reference correct commit SHA-1 ID
- Add Fixes tag
- Link to v1: https://lore.kernel.org/all/20230214102317.382769-1-michael.thalmeier@hale.at
---
drivers/tty/ttynull.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/tty/ttynull.c b/drivers/tty/ttynull.c
index 1d4438472442..6e9323544a7d 100644
--- a/drivers/tty/ttynull.c
+++ b/drivers/tty/ttynull.c
@@ -40,6 +40,12 @@ static unsigned int ttynull_write_room(struct tty_struct *tty)
return 65536;
}
+
+static void ttynull_console_write(struct console *co, const char *buf,
+ unsigned count)
+{
+}
+
static const struct tty_operations ttynull_ops = {
.open = ttynull_open,
.close = ttynull_close,
@@ -56,6 +62,7 @@ static struct tty_driver *ttynull_device(struct console *c, int *index)
static struct console ttynull_console = {
.name = "ttynull",
+ .write = ttynull_console_write,
.device = ttynull_device,
};
--
2.39.1
Powered by blists - more mailing lists