acpi: Fix use-before-initialization bug
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 2 Jun 2011 01:21:25 +0000 (09:21 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 2 Jun 2011 01:24:01 +0000 (09:24 +0800)
Reported-by: swildner@
sys/dev/acpica5/acpi_cpu_pstate.c

index 84ac626..c99cfd4 100644 (file)
@@ -295,6 +295,8 @@ acpi_pst_attach(device_t dev)
        buf.Length = ACPI_ALLOCATE_BUFFER;
        status = AcpiEvaluateObject(sc->pst_handle, "_PSD", NULL, &buf);
        if (!ACPI_FAILURE(status)) {
+               obj = (ACPI_OBJECT *)buf.Pointer;
+
                if (acpi_pst_domain_id > 0) {
                        device_printf(dev, "Missing _PSD for certain CPUs\n");
                        AcpiOsFree(obj);
@@ -302,7 +304,6 @@ acpi_pst_attach(device_t dev)
                }
                acpi_pst_domain_id = -1;
 
-               obj = (ACPI_OBJECT *)buf.Pointer;
                if (ACPI_PKG_VALID_EQ(obj, 1)) {
                        dom = acpi_pst_domain_create_pkg(dev,
                                &obj->Package.Elements[0]);