Author: cgutman Date: Thu Mar 11 23:15:21 2010 New Revision: 46119
URL: http://svn.reactos.org/svn/reactos?rev=46119&view=rev Log: - Fix the resource parsing loops to correct a memory corruption issue - Return the correct failure status if ExAllocatePool fails
Modified: trunk/reactos/drivers/bus/acpi/buspdo.c
Modified: trunk/reactos/drivers/bus/acpi/buspdo.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/buspdo.c?r... ============================================================================== --- trunk/reactos/drivers/bus/acpi/buspdo.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/acpi/buspdo.c [iso-8859-1] Thu Mar 11 23:15:21 2010 @@ -585,7 +585,6 @@ PPDO_DEVICE_DATA DeviceData, PIRP Irp ) { - BOOLEAN Done; ULONG NumberOfResources = 0; PCM_RESOURCE_LIST ResourceList; PCM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor; @@ -595,7 +594,6 @@ ULONG ResourceListSize; ULONG i;
- /* Get current resources */ Buffer.Length = 0; AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer); @@ -619,8 +617,7 @@
resource= Buffer.Pointer; /* Count number of resources */ - Done = FALSE; - while (!Done) + while (resource->Type != ACPI_RESOURCE_TYPE_END_TAG) { switch (resource->Type) { @@ -641,13 +638,9 @@ NumberOfResources++; break; } - case ACPI_RESOURCE_TYPE_END_TAG: - { - Done = TRUE; - break; - } default: { + DPRINT1("Unknown resource type: %d\n", resource->Type); break; } } @@ -659,7 +652,10 @@ ResourceList = (PCM_RESOURCE_LIST)ExAllocatePool(PagedPool, ResourceListSize);
if (!ResourceList) - return FALSE; + { + ExFreePool(Buffer.Pointer); + return STATUS_INSUFFICIENT_RESOURCES; + } ResourceList->Count = 1; ResourceList->List[0].InterfaceType = Internal; /* FIXME */ ResourceList->List[0].BusNumber = 0; /* We're the only ACPI bus device in the system */ @@ -669,8 +665,7 @@ ResourceDescriptor = ResourceList->List[0].PartialResourceList.PartialDescriptors;
/* Fill resources list structure */ - Done = FALSE; - while (!Done) + while (resource->Type != ACPI_RESOURCE_TYPE_END_TAG) { switch (resource->Type) { @@ -737,14 +732,8 @@ ResourceDescriptor++; break; } - case ACPI_RESOURCE_TYPE_END_TAG: - { - Done = TRUE; - break; - } default: { - DPRINT1("Unhandled resource type\n"); break; } } @@ -761,7 +750,6 @@ PPDO_DEVICE_DATA DeviceData, PIRP Irp ) { - BOOLEAN Done; ULONG NumberOfResources = 0; ACPI_STATUS AcpiStatus; ACPI_BUFFER Buffer; @@ -796,8 +784,7 @@
resource= Buffer.Pointer; /* Count number of resources */ - Done = FALSE; - while (!Done) + while (resource->Type != ACPI_RESOURCE_TYPE_END_TAG) { switch (resource->Type) { @@ -818,11 +805,6 @@ NumberOfResources++; break; } - case ACPI_RESOURCE_TYPE_END_TAG: - { - Done = TRUE; - break; - } default: { break; @@ -837,7 +819,7 @@ if (!RequirementsList) { ExFreePool(Buffer.Pointer); - return STATUS_SUCCESS; + return STATUS_INSUFFICIENT_RESOURCES; } RequirementsList->ListSize = RequirementsListSize; RequirementsList->InterfaceType = Internal; @@ -850,8 +832,7 @@ RequirementDescriptor = RequirementsList->List[0].Descriptors;
/* Fill resources list structure */ - Done = FALSE; - while (!Done) + while (resource->Type != ACPI_RESOURCE_TYPE_END_TAG) { switch (resource->Type) { @@ -920,14 +901,8 @@ RequirementDescriptor++; break; } - case ACPI_RESOURCE_TYPE_END_TAG: - { - Done = TRUE; - break; - } default: { - DPRINT1("Unhandled resource type\n"); break; } }