Linux USB
 help / color / mirror / Atom feed
* [PATCH 0/2] usb: gadget: fix max3420_udc endpoint index and bind without pullup
@ 2026-11-25  9:05 Aristo Chen
  2026-11-25  9:05 ` [PATCH 1/2] usb: gadget: max3420_udc: fix out of bounds endpoint index from wIndex Aristo Chen
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Aristo Chen @ 2026-11-25  9:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Neill Kapron
  Cc: Alan Stern, Krishna Kurapati, Jassi Brar, linux-usb, Aristo Chen

This series fixes two bugs that I found while looking at max3420_udc.

Patch 1 fixes an out of bounds array index in the SETUP handling of
max3420_udc. The endpoint number comes from wIndex, which the host
controls, and the driver uses it without a range check.

Patch 2 fixes the gadget core. Since v6.7, gadget_bind_driver() fails
when the connect step returns an error, and that step returns
-EOPNOTSUPP when the UDC has no pullup callback. So no gadget driver
can bind to such a UDC. This affects max3420_udc and four other UDC
drivers.

Patch 1 comes first so that the bounds check is in place when patch 2
makes the bind work again. Mainline v5.7 to v6.6 have the driver but
not the bind problem, so they only need patch 1.

I do not have the hardware. I tested with a KUnit test under User Mode
Linux that emulates the chip on a fake SPI controller. It gives the
driver SETUP packets and records the answers. With KASAN and UBSAN, on
usb-linus:

  no patch:       the gadget driver does not bind (-EOPNOTSUPP)
  patch 1 only:   the same, the driver still cannot bind
  patch 2 only:   it binds, bad endpoint numbers give UBSAN and KASAN
                  reports
  both patches:   the tests pass, no reports

I also built both files with W=1 for x86_64 and arm64.

I did not test the other UDC drivers that patch 2 affects.

The pullup callbacks of pxa25x_udc, pxa27x_udc and fsl_udc_core can
return -EOPNOTSUPP themselves. This series does not change how the
bind handles that.

The test is not part of this series. I can send it on request.

AI tools were used for this series. The out of bounds index in patch 1
was found by an AI code review of the driver. I used an AI coding
assistant (Claude Code) to write the KUnit test, both patches and their
descriptions. Running that test showed the bind problem that patch 2
fixes. A second AI tool (GitHub Copilot) reviewed the patches. I have
reviewed all of it.

Aristo Chen (2):
  usb: gadget: max3420_udc: fix out of bounds endpoint index from wIndex
  usb: gadget: udc: do not fail bind when the UDC has no pullup callback

 drivers/usb/gadget/udc/core.c        | 9 ++++++---
 drivers/usb/gadget/udc/max3420_udc.c | 8 +++++++-
 2 files changed, 13 insertions(+), 4 deletions(-)


base-commit: b0baaf6cbb16bc773d0c76916aac17c44a6cd557
-- 
2.53.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-25  9:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25  9:05 [PATCH 0/2] usb: gadget: fix max3420_udc endpoint index and bind without pullup Aristo Chen
2026-11-25  9:05 ` [PATCH 1/2] usb: gadget: max3420_udc: fix out of bounds endpoint index from wIndex Aristo Chen
2026-11-25  9:05 ` [PATCH 2/2] usb: gadget: udc: do not fail bind when the UDC has no pullup callback Aristo Chen
2026-11-25  9:25 ` [PATCH 0/2] usb: gadget: fix max3420_udc endpoint index and bind without pullup sashiko-bot

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