usb_host: Fixed incorrect opening devices from multiple clients

1. During USBH device open both queues (idle and pending) must be checked.
2. Don't overwrite already allocated endpoints
This commit is contained in:
Tomas Rezucha 2022-10-10 11:52:48 +02:00 committed by Darian Leung
parent 166effd4b8
commit 9e145c5d30

View File

@ -536,7 +536,7 @@ esp_err_t usbh_dev_open(uint8_t dev_addr, usb_device_handle_t *dev_hdl)
goto exit; goto exit;
} }
} }
TAILQ_FOREACH(dev_obj, &p_usbh_obj->dynamic.devs_idle_tailq, dynamic.tailq_entry) { TAILQ_FOREACH(dev_obj, &p_usbh_obj->dynamic.devs_pending_tailq, dynamic.tailq_entry) {
if (dev_obj->constant.address == dev_addr) { if (dev_obj->constant.address == dev_addr) {
found_dev_obj = dev_obj; found_dev_obj = dev_obj;
goto exit; goto exit;
@ -783,7 +783,7 @@ esp_err_t usbh_ep_alloc(usb_device_handle_t dev_hdl, usbh_ep_config_t *ep_config
if (is_in && dev_obj->mux_protected.ep_in[addr - 1] == NULL) { //Is an IN EP if (is_in && dev_obj->mux_protected.ep_in[addr - 1] == NULL) { //Is an IN EP
dev_obj->mux_protected.ep_in[addr - 1] = pipe_hdl; dev_obj->mux_protected.ep_in[addr - 1] = pipe_hdl;
assigned = true; assigned = true;
} else if (dev_obj->mux_protected.ep_out[addr - 1] == NULL) { //Is an OUT EP } else if (!is_in && dev_obj->mux_protected.ep_out[addr - 1] == NULL) { //Is an OUT EP
dev_obj->mux_protected.ep_out[addr - 1] = pipe_hdl; dev_obj->mux_protected.ep_out[addr - 1] = pipe_hdl;
assigned = true; assigned = true;
} }