Skip to contentSkip to conversation

hw/usb/core: fix inconsistent ep and pid (UBS_TOKEN_SETUP)

PATCH New Qiang Liu 1 participant 1 message Jan 29, 2023

lore
Share & tools
lore

Qiang Liu

author
#0 lore raw

PATCH 1/1 hw/usb/core: fix inconsistent ep and pid (UBS_TOKEN_SETUP)

Sometimes, ep is not enforced to 0 when pid is USB_TOKEN_SETUP. I trigger this through dwc2
(https://lists.gnu.org/archive/html/qemu-devel/2021-06/msg07179.html).
A similar bug was found [here](https://gitlab.com/qemu-project/qemu/-/issues/119) and [here](https://gitlab.com/qemu-project/qemu/-/issues/303).

Fixes 25d5de7d81a5 ("usb: link packets to endpoints not devices")

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/119
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/303

Cc Paul Zimmerman <[email protected]>
---
 hw/usb/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/usb/core.c +1 -1
index 975f76250a..eb50a7bff8 100644
@@ -738,7 +738,7 @@ struct USBEndpoint *usb_ep_get(USBDevice *dev, int pid, int ep)
     struct USBEndpoint *eps;
 
     assert(dev != NULL);
-    if (ep == 0) {
+    if (ep == 0 || pid == USB_TOKEN_SETUP) {
         return &dev->ep_ctl;
     }
     assert(pid == USB_TOKEN_IN || pid == USB_TOKEN_OUT);
Signature · 1 line
2.25.1