mirror of
https://github.com/apache/nuttx.git
synced 2026-06-08 18:37:46 +08:00
38ba0aefca
An off-by-one error caused invalid memory to be accessed when the last port was used. The first entry, at index 0, was never used. The USB standard uses 1-based numbering for hub ports. This number was used to index an array. This change converts the port number to a zero-based port index when the array is accessed. The zero-based value in the port field of the usbhost_hubport_s structure is also converted before printing. For testing, this bug was exposed on a 4 port hub when port 4 was used after changing USBHUB_MAX_PORTS to 4 in hub.h. The bug should also be triggered without changing hub.h if a 7 port hub is available.