diff options
Diffstat (limited to 'core/usbh_core.c')
| -rw-r--r-- | core/usbh_core.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/core/usbh_core.c b/core/usbh_core.c index b7f762ea..8aa92588 100644 --- a/core/usbh_core.c +++ b/core/usbh_core.c @@ -242,7 +242,7 @@ static int parse_config_descriptor(struct usbh_hubport *hport, struct usb_config return -USB_ERR_NOMEM; } - if (cur_ep_num >= CONFIG_USBHOST_MAX_ENDPOINTS) { + if (cur_ep_num > CONFIG_USBHOST_MAX_ENDPOINTS) { USB_LOG_ERR("Endpoint num %d overflow\r\n", cur_ep_num); return -USB_ERR_NOMEM; } @@ -272,6 +272,12 @@ static int parse_config_descriptor(struct usbh_hubport *hport, struct usb_config return -USB_ERR_INVAL; } ep_desc = (struct usb_endpoint_descriptor *)p; + + if (cur_ep >= CONFIG_USBHOST_MAX_ENDPOINTS) { + USB_LOG_ERR("Endpoint num %d overflow\r\n", cur_ep); + return -USB_ERR_NOMEM; + } + memcpy(&hport->config.intf[cur_iface].altsetting[cur_alt_setting].ep[cur_ep].ep_desc, ep_desc, 7); cur_ep++; break; |
