summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--class/hub/usbh_hub.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/class/hub/usbh_hub.c b/class/hub/usbh_hub.c
index 008c600c..f414f1e9 100644
--- a/class/hub/usbh_hub.c
+++ b/class/hub/usbh_hub.c
@@ -373,6 +373,11 @@ static int usbh_hub_connect(struct usbh_hubport *hport, uint8_t intf)
hub->tt_think = ((hub->hub_desc.wHubCharacteristics & HUB_CHAR_TTTT_MASK) >> 5);
}
+ if (hub->nports > CONFIG_USBHOST_MAX_EHPORTS) {
+ USB_LOG_ERR("Hub nports %u overflow\r\n", hub->nports);
+ return -USB_ERR_NOMEM;
+ }
+
for (uint8_t port = 0; port < hub->nports; port++) {
hub->child[port].port = port + 1;
hub->child[port].parent = hub;