All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Thalmeier <michael.thalmeier@hale.at>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jirislaby@kernel.org>,
	Vincent Whitchurch <vincent.whitchurch@axis.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] tty: ttynull: implement console write
Date: Tue, 14 Feb 2023 11:23:17 +0100	[thread overview]
Message-ID: <20230214102317.382769-1-michael.thalmeier@hale.at> (raw)

Since commit 3579b59c7edc475013ae769a2d26d99733c95f13 ("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.

Signed-off-by: Michael Thalmeier <michael.thalmeier@hale.at>
Cc: stable@vger.kernel.org
---
 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


             reply	other threads:[~2023-02-14 10:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-14 10:23 Michael Thalmeier [this message]
2023-02-14 10:50 ` [PATCH] tty: ttynull: implement console write Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230214102317.382769-1-michael.thalmeier@hale.at \
    --to=michael.thalmeier@hale.at \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vincent.whitchurch@axis.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.