Re: [PATCH] pps: clients: ldisc: Fix uninitialized info.echo in pps_tty_open()
From: Rodolfo Giometti
Date: Tue Dec 01 2026 - 03:30:52 EST
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@xxxxxxxxxx>
> ---
> 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@xxxxxxxxxxxx>
--
GNU/Linux Solutions e-mail: giometti@xxxxxxxxxxxx
Linux Device Driver giometti@xxxxxxxx
Embedded Systems phone: +39 349 2432127
UNIX programming