Kernel: Prevent integer overflow in USB::Hub::check_for_port_updates()

The maximum valid value is 255, so max + 1 doesn't fit in a u8.
This commit is contained in:
Idan Horowitz 2024-05-18 21:16:23 +03:00 committed by Andreas Kling
parent 80dad2d0b5
commit b4cdd6a55c
Notes: sideshowbarker 2024-07-17 03:18:29 +09:00

View file

@ -145,7 +145,8 @@ void Hub::remove_children_from_sysfs()
void Hub::check_for_port_updates()
{
for (u8 port_number = 1; port_number < m_hub_descriptor.number_of_downstream_ports + 1; ++port_number) {
for (u8 port_index = 0; port_index < m_hub_descriptor.number_of_downstream_ports; ++port_index) {
u8 port_number = port_index + 1;
dbgln_if(USB_DEBUG, "USB Hub: Checking for port updates on port {}...", port_number);
HubStatus port_status {};