- We forget that AE_BUFFER_OVERFLOW is normal and expected since our buffer length...
authorCameron Gutman <aicommander@gmail.com>
Wed, 10 Mar 2010 22:25:40 +0000 (22:25 +0000)
committerCameron Gutman <aicommander@gmail.com>
Wed, 10 Mar 2010 22:25:40 +0000 (22:25 +0000)
 - For any device that actually had resources we would return STATUS_SUCCESS without building a resource list and if the device didn't have resources we would end up freeing a NULL pointer, storing stack trash in Irp->IoStatus.Information, and then returning STATUS_SUCCESS
 - Fixes reporting device resources (and possibly the VBox additions crash with ACPI enabled)

svn path=/trunk/; revision=46080

reactos/drivers/bus/acpi/buspdo.c

index 25fbe32..e7cc65b 100644 (file)
@@ -599,23 +599,23 @@ Bus_PDO_QueryResources(
     /* Get current resources */
     Buffer.Length = 0;
     AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer);
-    if (!ACPI_SUCCESS(AcpiStatus))
+    if ((!ACPI_SUCCESS(AcpiStatus) && AcpiStatus != AE_BUFFER_OVERFLOW) ||
+        Buffer.Length == 0)
     {
-      return STATUS_SUCCESS;
+      return Irp->IoStatus.Status;
     }
-    if (Buffer.Length > 0)
+
+    Buffer.Pointer = ExAllocatePool(PagedPool, Buffer.Length);
+    if (!Buffer.Pointer)
+      return STATUS_INSUFFICIENT_RESOURCES;
+
+    AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer);
+    if (!ACPI_SUCCESS(AcpiStatus))
     {
-      Buffer.Pointer = ExAllocatePool(PagedPool, Buffer.Length);
-      if (!Buffer.Pointer)
-      {
-        ASSERT(FALSE);
-      }
-      AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer);
-      if (!ACPI_SUCCESS(AcpiStatus))
-      {
-        ASSERT(FALSE);
-      }
-       }
+      DPRINT1("AcpiGetCurrentResources #2 failed (0x%x)\n", AcpiStatus);
+      ASSERT(FALSE);
+      return STATUS_UNSUCCESSFUL;
+    }
 
        resource= Buffer.Pointer;
        /* Count number of resources */
@@ -776,23 +776,23 @@ Bus_PDO_QueryResourceRequirements(
     /* Get current resources */
     Buffer.Length = 0;
     AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer);
-    if (!ACPI_SUCCESS(AcpiStatus))
+    if ((!ACPI_SUCCESS(AcpiStatus) && AcpiStatus != AE_BUFFER_OVERFLOW) ||
+        Buffer.Length == 0)
     {
-      return STATUS_SUCCESS;
+      return Irp->IoStatus.Status;
     }
-    if (Buffer.Length > 0)
+
+    Buffer.Pointer = ExAllocatePool(PagedPool, Buffer.Length);
+    if (!Buffer.Pointer)
+      return STATUS_INSUFFICIENT_RESOURCES;
+
+    AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer);
+    if (!ACPI_SUCCESS(AcpiStatus))
     {
-      Buffer.Pointer = ExAllocatePool(PagedPool, Buffer.Length);
-      if (!Buffer.Pointer)
-      {
-        ASSERT(FALSE);
-      }
-      AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer);
-      if (!ACPI_SUCCESS(AcpiStatus))
-      {
-        ASSERT(FALSE);
-      }
-       }
+      DPRINT1("AcpiGetCurrentResources #2 failed (0x%x)\n", AcpiStatus);
+      ASSERT(FALSE);
+      return STATUS_UNSUCCESSFUL;
+    }
 
        resource= Buffer.Pointer;
        /* Count number of resources */