From: Cheng Yongkang <teel4res@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alan Stern <stern@rowland.harvard.edu>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [BUG] usb: core: resume clears needs_altsetting0 even on failure
Date: Sun, 15 Nov 2026 08:36:54 -0800 [thread overview]
Message-ID: <20261115163654.226373-1-teel4res@gmail.com> (raw)
Hi Greg, Alan,
I hit a corner case in usb_resume_interface(). It needs a device that
fails SET_INTERFACE(0) both when the driver is unbound and again at
resume, so it may not be worth fixing.
needs_altsetting0 is handled in three places. usb_unbind_interface()
sets it when the switch to altsetting 0 fails, and
usb_probe_interface() clears it only after the switch succeeds. But
usb_resume_interface() clears it even when its deferred
usb_set_interface(..., 0) fails. probe then skips the switch, and the
next driver binds with the interface still at the old altsetting.
On v7.3 with raw-gadget and dummy_hcd, the gadget stalled
SET_INTERFACE(0) at unbind and at resume. usbtest then bound to the
interface while it was at altsetting 1, and its URB failed with
-ENOENT. The code is unchanged in next-20261113.
Clearing the flag only on success, as probe does, fixes it:
- usb_set_interface(udev, intf->altsetting[0].
- desc.bInterfaceNumber, 0);
- intf->needs_altsetting0 = 0;
+ if (!usb_set_interface(udev, intf->altsetting[0].
+ desc.bInterfaceNumber, 0))
+ intf->needs_altsetting0 = 0;
With the version I tested, which also logged the error, probe retried
the switch and refused to bind while the gadget kept stalling, and
normal resume was unchanged. I can send a patch if you want one.
Thanks,
Cheng Yongkang
next reply other threads:[~2026-11-15 16:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 16:36 Cheng Yongkang [this message]
2026-11-16 9:33 ` [BUG] usb: core: resume clears needs_altsetting0 even on failure Greg Kroah-Hartman
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=20261115163654.226373-1-teel4res@gmail.com \
--to=teel4res@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/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