Guard against unsupported or invalid USB controller types.

This commit is contained in:
Martin Whitaker 2022-09-09 19:48:59 +01:00
parent 03a5222ee2
commit c41159084d

View File

@ -751,6 +751,10 @@ void find_usb_keyboards(bool pause_if_none)
uint16_t class_code = pci_config_read16(bus, dev, func, 0x0a);
if (class_code == 0x0c03) {
controller_type[func] = pci_config_read8(bus, dev, func, 0x09) >> 4;
if (controller_type[func] >= MAX_HCI_TYPE) {
// Unsupported or invalid controller type - ignore it.
controller_type[func] = NOT_HCI;
}
// We need to initialise EHCI controllers before initialising any of their companion
// controllers, so do it now.
if (controller_type[func] == EHCI) {