mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: Rodolfo Giometti <giometti@enneenne.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jirislaby@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	 linux-serial@vger.kernel.org, llvm@lists.linux.dev,
	 linux-kernel@vger.kernel.org, Ian Rogers <irogers@google.com>
Subject: [PATCH] pps: clients: ldisc: Fix uninitialized info.echo in pps_tty_open()
Date: Mon, 30 Nov 2026 14:54:04 -0800	[thread overview]
Message-ID: <20261130225404.97988-1-irogers@google.com> (raw)

pps_tty_open() declares struct pps_source_info info on the stack without
an initializer and never initializes info.echo before calling
pps_register_source(&info, ...). pps_register_source() copies the entire
struct via pps->info = *info, leaving pps->info.echo with uninitialized
stack contents that are read by echo_show() when /sys/class/pps/ppsX/echo
is read.

Initialize info using a designated initializer so info.echo and any
remaining fields are zero-initialized, found with Clang's
require_explicit_initialization attribute.

Fixes: a0880df0ccde ("pps: serial clients support")
Signed-off-by: Ian Rogers <irogers@google.com>
---
Note: Found using Clang's require_explicit_initialization attribute;
an AI coding assistant helped audit call sites, verify Fixes commits,
and draft the changelog.

 drivers/pps/clients/pps-ldisc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/pps/clients/pps-ldisc.c b/drivers/pps/clients/pps-ldisc.c
index fa5660f3c4b7..dc24b2a32236 100644
--- a/drivers/pps/clients/pps-ldisc.c
+++ b/drivers/pps/clients/pps-ldisc.c
@@ -40,19 +40,19 @@ static int (*alias_n_tty_open)(struct tty_struct *tty);
 
 static int pps_tty_open(struct tty_struct *tty)
 {
-	struct pps_source_info info;
+	struct pps_source_info info = {
+		.owner = THIS_MODULE,
+		.mode = PPS_CAPTUREBOTH |
+			PPS_OFFSETASSERT | PPS_OFFSETCLEAR |
+			PPS_CANWAIT | PPS_TSFMT_TSPEC,
+	};
 	struct tty_driver *drv = tty->driver;
 	int index = tty->index + drv->name_base;
 	struct pps_device *pps;
 	int ret;
 
-	info.owner = THIS_MODULE;
-	info.dev = NULL;
 	snprintf(info.name, PPS_MAX_NAME_LEN, "%s%d", drv->driver_name, index);
 	snprintf(info.path, PPS_MAX_NAME_LEN, "/dev/%s%d", drv->name, index);
-	info.mode = PPS_CAPTUREBOTH | \
-			PPS_OFFSETASSERT | PPS_OFFSETCLEAR | \
-			PPS_CANWAIT | PPS_TSFMT_TSPEC;
 
 	pps = pps_register_source(&info, PPS_CAPTUREBOTH | \
 				PPS_OFFSETASSERT | PPS_OFFSETCLEAR);

base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
-- 
2.56.1.839.g22a8290db9-goog


                 reply	other threads:[~2026-11-30 22:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261130225404.97988-1-irogers@google.com \
    --to=irogers@google.com \
    --cc=giometti@enneenne.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®