From nobody Fri Sep 12 02:26:52 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BFC7C61DA4 for ; Tue, 14 Feb 2023 10:24:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232200AbjBNKYk (ORCPT ); Tue, 14 Feb 2023 05:24:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231526AbjBNKYj (ORCPT ); Tue, 14 Feb 2023 05:24:39 -0500 X-Greylist: delayed 63 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 14 Feb 2023 02:24:37 PST Received: from gw.hale.at (gw.hale.at [89.26.116.210]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EF7D83CE for ; Tue, 14 Feb 2023 02:24:36 -0800 (PST) Received: from unknown (HELO mail3.hale) ([192.168.100.5]) by gw.hale.at with ESMTP; 14 Feb 2023 11:23:31 +0100 Received: from localhost (localhost [127.0.0.1]) by mail3.hale (Postfix) with ESMTP id E9BF2BD58B; Tue, 14 Feb 2023 11:23:30 +0100 (CET) Received: from mail3.hale ([127.0.0.1]) by localhost (mail3.hale [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id tdnegw2pt85W; Tue, 14 Feb 2023 11:23:30 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail3.hale (Postfix) with ESMTP id 9B80BBD594; Tue, 14 Feb 2023 11:23:30 +0100 (CET) X-Virus-Scanned: amavisd-new at mail3.hale Received: from mail3.hale ([127.0.0.1]) by localhost (mail3.hale [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id vu8CIDnZXLGH; Tue, 14 Feb 2023 11:23:30 +0100 (CET) Received: from entw47.HALE.at (unknown [192.168.100.117]) by mail3.hale (Postfix) with ESMTP id 87757BD58B; Tue, 14 Feb 2023 11:23:30 +0100 (CET) From: Michael Thalmeier To: Greg Kroah-Hartman , Jiri Slaby , Vincent Whitchurch Cc: linux-kernel@vger.kernel.org Subject: [PATCH] tty: ttynull: implement console write Date: Tue, 14 Feb 2023 11:23:17 +0100 Message-Id: <20230214102317.382769-1-michael.thalmeier@hale.at> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 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; } =20 + +static void ttynull_console_write(struct console *co, const char *buf, + unsigned count) +{ +} + static const struct tty_operations ttynull_ops =3D { .open =3D ttynull_open, .close =3D ttynull_close, @@ -56,6 +62,7 @@ static struct tty_driver *ttynull_device(struct console *= c, int *index) =20 static struct console ttynull_console =3D { .name =3D "ttynull", + .write =3D ttynull_console_write, .device =3D ttynull_device, }; =20 --=20 2.39.1