Skip to content

usbhost_hub: Prevent crash when the last hub port is used.#9257

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
ldube:master
May 12, 2023
Merged

usbhost_hub: Prevent crash when the last hub port is used.#9257
xiaoxiang781216 merged 1 commit into
apache:masterfrom
ldube:master

Conversation

@ldube
Copy link
Copy Markdown
Contributor

@ldube ldube commented May 11, 2023

Summary

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.

Impact

Testing

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.

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.
@xiaoxiang781216 xiaoxiang781216 merged commit 38ba0ae into apache:master May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants