From: sashiko-bot@kernel.org
To: "Shuai Liu" <847807867@qq.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: gadget: uac1_legacy: fix double-close of sound device files
Date: Mon, 23 Nov 2026 14:01:50 +0000 [thread overview]
Message-ID: <sashiko-outbox-229355@kernel.org> (raw)
In-Reply-To: <tencent_7C654BDEA5891337506C7242C8FD481A9E05@qq.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] usb: gadget: uac1_legacy: missing Fixes: trailer in commit
message
--
commit 3da4b8607e9ed8f8aab229a9303b5baa05b42d1a
Author: Shuai Liu <847807867@qq.com>
> usb: gadget: uac1_legacy: fix double-close of sound device files
>
> syzbot reports:
>
> VFS: Close: file count is 0 (f_op=snd_ctl_f_ops)
> kernel BUG at fs/open.c
> ...
> Call Trace:
> filp_flush+0x...
> filp_close+0x...
> gaudio_close_snd_dev
> gaudio_cleanup
> f_audio_bind
> usb_add_function
>
> gaudio_close_snd_dev() closes the control/playback/capture device
> files but does not clear the file pointers afterwards, so it is not
> idempotent. gaudio_cleanup() is invoked both from the f_audio_bind()
> failure path and from f_audio_free(). When a bind attempt fails after
> gaudio_setup() has opened the sound device files (e.g. because
> usb_ep_autoconfig() cannot find an isochronous endpoint), the files
> get closed while audio_opts->bound stays true and the stale file
> pointers remain set. A subsequent bind of the same function instance
> skips gaudio_setup() and closes the already freed struct files again,
> triggering the file count corruption check in filp_flush().
>
> Make gaudio_close_snd_dev() clear the file pointer (and the PCM
> substream) after each close, and reset audio_opts->bound to false on
> the bind failure path so that a subsequent bind reopens the sound
> devices instead of reusing stale ones.
>
> Verified with a QEMU setup (dummy UDC provides no isochronous
> endpoints, so every bind fails): without the patch the second bind
> attempt hits "VFS: Close: file count is 0 ... kernel BUG at
> fs/open.c"; with the patch ten consecutive bind attempts complete
> cleanly.
>
> Reported-by: syzbot+592c653b056459925299@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=592c653b056459925299
> Signed-off-by: Shuai Liu <847807867@qq.com>
[Severity: Low]
Commit f3a3406b3f56 ("usb: gadget: f_uac1: convert to new function interface
with backward compatibility") added the audio_opts->bound guard around
gaudio_setup() in f_audio_bind() while calling gaudio_cleanup() on both the
bind failure path and function teardown. Should this include a Fixes: tag?
Fixes: f3a3406b3f56 ("usb: gadget: f_uac1: convert to new function interface with backward compatibility")
--
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_7C654BDEA5891337506C7242C8FD481A9E05@qq.com?part=1
prev parent reply other threads:[~2026-11-23 14:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 13:48 [PATCH] usb: gadget: uac1_legacy: fix double-close of sound device files Shuai Liu
2026-11-23 14:01 ` 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-229355@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=847807867@qq.com \
--cc=linux-usb@vger.kernel.org \
--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