[BUG] usb: core: resume clears needs_altsetting0 even on failure
From: Cheng Yongkang
Date: Sun Nov 15 2026 - 11:37:04 EST
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