[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] hw/usb/core: fix inconsistent ep and pid (UBS_TOKEN_SETUP)
From: |
Qiang Liu |
Subject: |
[PATCH] hw/usb/core: fix inconsistent ep and pid (UBS_TOKEN_SETUP) |
Date: |
Sun, 29 Jan 2023 18:54:06 +0800 |
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 <pauldzim@gmail.com>
Signed-off-by: Qiang Liu <cyruscyliu@gmail.com>
---
hw/usb/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/usb/core.c b/hw/usb/core.c
index 975f76250a..eb50a7bff8 100644
--- a/hw/usb/core.c
+++ b/hw/usb/core.c
@@ -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);
--
2.25.1
- [PATCH] hw/usb/core: fix inconsistent ep and pid (UBS_TOKEN_SETUP),
Qiang Liu <=