diff options
| author | sakumisu <[email protected]> | 2025-10-09 21:27:17 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2025-10-09 21:27:17 +0800 |
| commit | ec82b8a36cbe093cd64219d644ac51a6b66e6c6c (patch) | |
| tree | 73a6a93d682740e46c6a311199a712f78265f77a | |
| parent | 5fcbbcd93a942702aff31e6392b4e185724f9e5b (diff) | |
update(hub/usbh_hub): add check for nports
Signed-off-by: sakumisu <[email protected]>
| -rw-r--r-- | class/hub/usbh_hub.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/class/hub/usbh_hub.c b/class/hub/usbh_hub.c index be061cd8..53382cd2 100644 --- a/class/hub/usbh_hub.c +++ b/class/hub/usbh_hub.c @@ -387,6 +387,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; |
