summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormlwang <[email protected]>2025-07-10 21:33:24 +0800
committersakumisu <[email protected]>2025-07-10 21:45:45 +0800
commit4093a3b01db3e104df1ced21d6af66fbd9960f30 (patch)
tree6eedbe7ffa63fb6c363ac1f7f30d89b4981edd60
parent9de928d6af1b3dcd121c4ebf5d8761b90e72b0c1 (diff)
fix(port/ehci): Fix the urb leak when there is no data in the control transmission
-rw-r--r--port/ehci/usb_hc_ehci.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/port/ehci/usb_hc_ehci.c b/port/ehci/usb_hc_ehci.c
index 7c314354..c6a72e0f 100644
--- a/port/ehci/usb_hc_ehci.c
+++ b/port/ehci/usb_hc_ehci.c
@@ -336,10 +336,8 @@ static struct ehci_qh_hw *ehci_control_urb_init(struct usbh_bus *bus, struct usb
}
qtd_setup = ehci_qtd_alloc(bus);
- qtd_data = ehci_qtd_alloc(bus);
qtd_status = ehci_qtd_alloc(bus);
-
- USB_ASSERT_MSG(qtd_setup && qtd_data && qtd_status, "ctrl qtd alloc failed");
+ USB_ASSERT_MSG(qtd_setup && qtd_status, "ctrl qtd alloc failed");
ehci_qh_fill(qh,
urb->hport->dev_addr,
@@ -363,6 +361,9 @@ static struct ehci_qh_hw *ehci_control_urb_init(struct usbh_bus *bus, struct usb
/* fill data qtd */
if (setup->wLength > 0) {
+ qtd_data = ehci_qtd_alloc(bus);
+ USB_ASSERT_MSG(qtd_data, "ctrl qtd alloc failed");
+
if ((setup->bmRequestType & 0x80) == 0x80) {
token = QTD_TOKEN_PID_IN;
} else {