From 8f118e25ecfe27ccf94b5a01023a4b703fda68ba Mon Sep 17 00:00:00 2001 From: Nate Lawson Date: Thu, 17 Feb 2005 19:00:14 +0000 Subject: [PATCH] Check for the address space type first before validating it. In particular, we want to return EOPNOTSUPP for FFixedHW no matter what the address. Submitted by: Bruno Ducrot --- sys/dev/acpica/acpi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 48f3cef115e..57f663e5991 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);