Skip to content

Commit

Permalink
usb_host: Fixed incorrect opening devices from multiple clients
Browse files Browse the repository at this point in the history
1. During USBH device open both queues (idle and pending) must be checked.
2. Don't overwrite already allocated endpoints
  • Loading branch information
tore-espressif authored and Dazza0 committed Nov 7, 2022
1 parent 166effd commit 9e145c5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/usb/usbh.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ esp_err_t usbh_dev_open(uint8_t dev_addr, usb_device_handle_t *dev_hdl)
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) {
found_dev_obj = dev_obj;
goto exit;
Expand Down Expand Up @@ -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
dev_obj->mux_protected.ep_in[addr - 1] = pipe_hdl;
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;
assigned = true;
}
Expand Down

0 comments on commit 9e145c5

Please sign in to comment.