mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rodolfo Giometti <giometti@enneenne.com>
To: Ian Rogers <irogers@google.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andrew Morton <akpm@linux-foundation.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
Subject: Re: [PATCH] pps: clients: ldisc: Fix uninitialized info.echo in pps_tty_open()
Date: Tue, 1 Dec 2026 09:30:35 +0100	[thread overview]
Message-ID: <7ed7c9d8-8a35-4203-8499-0f428a3e334d@enneenne.com> (raw)
In-Reply-To: <20261130225404.97988-1-irogers@google.com>

On 30/11/2026 23:54, Ian Rogers wrote:
> 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

Acked-by: Rodolfo Giometti <giometti@enneenne.com>

-- 
GNU/Linux Solutions                  e-mail: giometti@enneenne.com
Linux Device Driver                          giometti@linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming

      reply	other threads:[~2026-12-01  8:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 22:54 Ian Rogers
2026-12-01  8:30 ` Rodolfo Giometti [this message]

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=7ed7c9d8-8a35-4203-8499-0f428a3e334d@enneenne.com \
    --to=giometti@enneenne.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=irogers@google.com \
    --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®