Linux USB
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lin Tzu Yang" <rongh7426@gmail.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: gadget: f_uac1: fix return value of string attribute stores
Date: Mon, 30 Nov 2026 11:53:37 +0000	[thread overview]
Message-ID: <sashiko-outbox-240984@kernel.org> (raw)
In-Reply-To: <20261130115055.842820-1-rongh7426@gmail.com>

> The configfs store for the f_uac1 string attributes (function_name,
> p_it_name, c_it_name and the others) returns the result of scnprintf()
> with a size of min(sizeof(opts->name), len). That is at most len - 1,
> so every write is reported as short. The writer then writes the rest
> again; for the last byte the size is 1, nothing is stored and 0 is
> returned, and a writer that retries on a short write never finishes.
> Each retry also overwrites the name with what is left, so the name ends
> up empty.
> 
> With busybox in a QEMU arm64 guest (dummy_hcd), all of these hang until
> they are killed, and the name reads back empty afterwards:
> 
>   echo MyAudio > functions/uac1.0/function_name
>   printf NoNewline > functions/uac1.0/function_name
>   echo Mic > functions/uac1.0/p_it_name
> 
> This started when snprintf() was replaced by scnprintf(): snprintf()
> returned the full length of the string, which is len.
> 
> Do what f_uac2 does since commit 9499327714de ("usb: gadget: f_uac2: fix
> return value for UAC2_ATTRIBUTE_STRING store") and commit e60284b63245
> ("usb: gadget: f_uac2: fix non-newline-terminated function name"):
> return len, and strip only a trailing newline, so a name written without
> one keeps its last character.
> 
> Fixes: c1a371866db9 ("usb: gadget: f_uac1: Replace snprintf() with the safer scnprintf() variant")
> Cc: stable@vger.kernel.org
> Signed-off-by: Lin Tzu Yang <rongh7426@gmail.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130115055.842820-1-rongh7426@gmail.com?part=1

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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 11:50 [PATCH] usb: gadget: f_uac1: fix return value of string attribute stores Lin Tzu Yang
2026-11-30 11:53 ` sashiko-bot [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=sashiko-outbox-240984@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=rongh7426@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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