From c2bc34ee849f4c620c07f4473db46f399e221127 Mon Sep 17 00:00:00 2001 From: Darian Leung Date: Tue, 6 Dec 2022 18:10:45 +0800 Subject: [PATCH] usb: Fix incorrect bmRequestType direction flag in USB Host Library usb_host_transfer_submit_control() uses the incorrect bmRequestType direction flag. Therefore, when doing a transfer check, all transfers were mistakenly treated as OUT transfers (only affects transfer check and not actual transfer). --- components/usb/usb_host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/usb/usb_host.c b/components/usb/usb_host.c index ebbb00b33c..5550711724 100644 --- a/components/usb/usb_host.c +++ b/components/usb/usb_host.c @@ -1336,7 +1336,7 @@ esp_err_t usb_host_transfer_submit_control(usb_host_client_handle_t client_hdl, //Check that control transfer is valid HOST_CHECK(transfer->device_handle != NULL, ESP_ERR_INVALID_ARG); //Target device must be set usb_device_handle_t dev_hdl = transfer->device_handle; - bool xfer_is_in = ((usb_setup_packet_t *)transfer->data_buffer)->bmRequestType & USB_BM_REQUEST_TYPE_DIR_OUT; + bool xfer_is_in = ((usb_setup_packet_t *)transfer->data_buffer)->bmRequestType & USB_BM_REQUEST_TYPE_DIR_IN; usb_device_info_t dev_info; ESP_ERROR_CHECK(usbh_dev_get_info(dev_hdl, &dev_info)); HOST_CHECK(transfer_check(transfer, USB_TRANSFER_TYPE_CTRL, dev_info.bMaxPacketSize0, xfer_is_in), ESP_ERR_INVALID_ARG);