mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [BUG] usb: core: resume clears needs_altsetting0 even on failure
@ 2026-11-15 16:36 Cheng Yongkang
  0 siblings, 0 replies; only message in thread
From: Cheng Yongkang @ 2026-11-15 16:36 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Alan Stern, linux-usb, linux-kernel

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-15 16:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-15 16:36 [BUG] usb: core: resume clears needs_altsetting0 even on failure Cheng Yongkang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®