diff options
author | takawata <takawata@FreeBSD.org> | 2002-01-31 01:23:22 +0000 |
---|---|---|
committer | takawata <takawata@FreeBSD.org> | 2002-01-31 01:23:22 +0000 |
commit | b0b42236aa80431126dabf63f36ef60686a66444 (patch) | |
tree | a65fd31a873b38a05913b2f63841ae6ae9f600c9 /sys/dev | |
parent | fdc99f4021e5f4688253ad52ed691a1c58c0f8b5 (diff) | |
download | FreeBSD-src-b0b42236aa80431126dabf63f36ef60686a66444.zip FreeBSD-src-b0b42236aa80431126dabf63f36ef60686a66444.tar.gz |
Fix error handling.
PR:30665
Submitted by:TOMITA Yoshinori <yoshint@flab.fujitsu.co.jp>
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/acpica/acpi_ec.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/sys/dev/acpica/acpi_ec.c b/sys/dev/acpica/acpi_ec.c index b5d7e74..0f3db78 100644 --- a/sys/dev/acpica/acpi_ec.c +++ b/sys/dev/acpica/acpi_ec.c @@ -355,7 +355,7 @@ acpi_ec_attach(device_t dev) { struct acpi_ec_softc *sc; ACPI_STATUS Status; - + int errval = 0; FUNCTION_TRACE(__func__); /* @@ -373,7 +373,8 @@ acpi_ec_attach(device_t dev) if ((sc->ec_data_res = bus_alloc_resource(sc->ec_dev, SYS_RES_IOPORT, &sc->ec_data_rid, 0, ~0, 1, RF_ACTIVE)) == NULL) { device_printf(dev, "can't allocate data port\n"); - return_VALUE(ENXIO); + errval = ENXIO; + goto out; } sc->ec_data_tag = rman_get_bustag(sc->ec_data_res); sc->ec_data_handle = rman_get_bushandle(sc->ec_data_res); @@ -382,7 +383,8 @@ acpi_ec_attach(device_t dev) if ((sc->ec_csr_res = bus_alloc_resource(sc->ec_dev, SYS_RES_IOPORT, &sc->ec_csr_rid, 0, ~0, 1, RF_ACTIVE)) == NULL) { device_printf(dev, "can't allocate command/status port\n"); - return_VALUE(ENXIO); + errval = ENXIO; + goto out; } sc->ec_csr_tag = rman_get_bustag(sc->ec_csr_res); sc->ec_csr_handle = rman_get_bushandle(sc->ec_csr_res); @@ -396,7 +398,8 @@ acpi_ec_attach(device_t dev) ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "attaching GPE\n")); if ((Status = acpi_EvaluateInteger(sc->ec_handle, "_GPE", &sc->ec_gpebit)) != AE_OK) { device_printf(dev, "can't evaluate _GPE - %s\n", AcpiFormatException(Status)); - return_VALUE(ENXIO); + errval =ENXIO; + goto out; } /* @@ -411,7 +414,8 @@ acpi_ec_attach(device_t dev) EcGpeHandler, sc)) != AE_OK) { device_printf(dev, "can't install GPE handler for %s - %s\n", acpi_name(sc->ec_handle), AcpiFormatException(Status)); - return_VALUE(ENXIO); + errval = ENXIO; + goto out; } /* @@ -423,11 +427,19 @@ acpi_ec_attach(device_t dev) device_printf(dev, "can't install address space handler for %s - %s\n", acpi_name(sc->ec_handle), AcpiFormatException(Status)); panic("very suck"); - return_VALUE(ENXIO); + errval = ENXIO; + goto out; } ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "attach complete\n")); - return_VALUE(0); + out: + if(sc->ec_csr_res) + bus_release_resource(sc->ec_dev, SYS_RES_IOPORT, sc->ec_csr_rid, + sc->ec_csr_res); + if(sc->ec_data_res) + bus_release_resource(sc->ec_dev, SYS_RES_IOPORT, sc->ec_data_rid, + sc->ec_data_res); + return_VALUE(errval); } static void |