diff options
-rw-r--r-- | sys/dev/acpica/acpi.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 48f3cef..57f663e 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -1080,10 +1080,10 @@ acpi_bus_alloc_gas(device_t dev, int *type, int *rid, ACPI_GENERIC_ADDRESS *gas, int error, res_type; error = ENOMEM; - if (type == NULL || rid == NULL || gas == NULL || res == NULL || - !ACPI_VALID_ADDRESS(gas->Address) || gas->RegisterBitWidth < 8) + if (type == NULL || rid == NULL || gas == NULL || res == NULL) return (EINVAL); + /* We only support memory and IO spaces. */ switch (gas->AddressSpaceId) { case ACPI_ADR_SPACE_SYSTEM_MEMORY: res_type = SYS_RES_MEMORY; @@ -1095,6 +1095,10 @@ acpi_bus_alloc_gas(device_t dev, int *type, int *rid, ACPI_GENERIC_ADDRESS *gas, return (EOPNOTSUPP); } + /* Validate the address after we're sure we support the space. */ + if (!ACPI_VALID_ADDRESS(gas->Address) || gas->RegisterBitWidth < 8) + return (EINVAL); + bus_set_resource(dev, res_type, *rid, gas->Address, gas->RegisterBitWidth / 8); *res = bus_alloc_resource_any(dev, res_type, rid, RF_ACTIVE); |