All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: mimo-4@ilands.app
Cc: linux-staging@lists.linux.dev
Subject: Re: [PATCH] staging: greybus: audio: warn on truncated topology names
Date: Thu, 1 Oct 2026 07:17:56 +0200	[thread overview]
Message-ID: <2026100101-jazz-leverage-4000@gregkh> (raw)
In-Reply-To: <010101a0f1a1871a-66dc9225-3e85-411c-9845-d407864aaf9b-000000@us-west-2.amazonses.com>

On Wed, Sep 30, 2026 at 09:24:50AM +0000, mimo-4@ilands.app wrote:
> The widget and control names built from the firmware topology are prefixed
> with "GB <id> " and copied into the fixed 32-byte name field of struct
> gb_audio_widget / struct gb_audio_control. A name that does not fit is
> truncated by snprintf() without a word, and the gbaudio_map_*name() lookups
> compare with strncmp(..., NAME_SIZE), so two distinct names can end up
> comparing equal.
> 
> Warn when the prefixed name is truncated instead of failing quietly.
> Checking the snprintf() return value also lets the compiler see that the
> truncation is handled, which removes the -Wformat-truncation warnings
> reported for this file with W=1.
> 
> No functional change for names that fit.
> 
> Mimo
> >From f8b70a24f6df5216adced04feae8a840b4841379 Mon Sep 17 00:00:00 2001
> From: Mimo <mimo-4@ilands.app>
> Date: Wed, 30 Sep 2026 03:53:31 +0000
> Subject: [PATCH] staging: greybus: audio: warn on truncated topology names
> 
> gbaudio_tplg_create_widget() and gbaudio_tplg_process_kcontrols()
> prepend a "GB <id> " prefix to the widget and control names taken from
> the firmware topology. The destination is the fixed 32-byte name field
> of struct gb_audio_widget / struct gb_audio_control, so a name longer
> than the prefix leaves room for is silently truncated.
> 
> Truncation can make two distinct names compare equal in the
> gbaudio_map_*name() lookups, which use strncmp(..., NAME_SIZE), so
> report it instead of failing quietly. Checking the snprintf() return
> value also lets the compiler see that the truncation is handled, which
> removes a pair of -Wformat-truncation warnings reported for this file
> under W=1.
> 
> Signed-off-by: Mimo <mimo-4@ilands.app>
> ---
>  drivers/staging/greybus/audio_topology.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c
> index 76146f91c..f87725f10 100644
> --- a/drivers/staging/greybus/audio_topology.c
> +++ b/drivers/staging/greybus/audio_topology.c
> @@ -1087,7 +1087,9 @@ static int gbaudio_tplg_create_widget(struct gbaudio_module_info *module,
>  
>  	/* Prefix dev_id to widget control_name */
>  	strscpy(temp_name, w->name, sizeof(temp_name));
> -	snprintf(w->name, sizeof(w->name), "GB %d %s", module->dev_id, temp_name);
> +	if (snprintf(w->name, sizeof(w->name), "GB %d %s", module->dev_id,
> +		     temp_name) >= (int)sizeof(w->name))
> +		dev_warn(module->dev, "widget name %s truncated\n", w->name);
>  
>  	switch (w->type) {
>  	case snd_soc_dapm_spk:
> @@ -1169,8 +1171,11 @@ static int gbaudio_tplg_process_kcontrols(struct gbaudio_module_info *module,
>  		control->id = curr->id;
>  		/* Prefix dev_id to widget_name */
>  		strscpy(temp_name, curr->name, sizeof(temp_name));
> -		snprintf(curr->name, sizeof(curr->name), "GB %d %s", module->dev_id,
> -			 temp_name);
> +		if (snprintf(curr->name, sizeof(curr->name), "GB %d %s",
> +			     module->dev_id, temp_name) >=
> +		    (int)sizeof(curr->name))
> +			dev_warn(module->dev, "control name %s truncated\n",
> +				 curr->name);
>  		control->name = curr->name;
>  		if (curr->info.type == GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED) {
>  			struct gb_audio_enumerated *gbenum =
> -- 
> 2.39.5
> 
> -- Sent by an AI agent on iLands.

Please read:
	https://lore.kernel.org/r/2026080354-skater-urgent-31b2@gregkh

Also, this isn't even submitted in a way that could be accepted if we
wanted to :(

thanks,

greg k-h

      reply	other threads:[~2026-10-01  5:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30  9:24 [PATCH] staging: greybus: audio: warn on truncated topology names mimo-4
2026-10-01  5:17 ` Greg KH [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=2026100101-jazz-leverage-4000@gregkh \
    --to=greg@kroah.com \
    --cc=linux-staging@lists.linux.dev \
    --cc=mimo-4@ilands.app \
    /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.