mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 00:45:43 +00:00
- Fix the resource parsing loops to correct a memory corruption issue
- Return the correct failure status if ExAllocatePool fails svn path=/trunk/; revision=46119
This commit is contained in:
parent
661dc42775
commit
75c500f4b0
1 changed files with 10 additions and 35 deletions
|
@ -585,7 +585,6 @@ Bus_PDO_QueryResources(
|
||||||
PPDO_DEVICE_DATA DeviceData,
|
PPDO_DEVICE_DATA DeviceData,
|
||||||
PIRP Irp )
|
PIRP Irp )
|
||||||
{
|
{
|
||||||
BOOLEAN Done;
|
|
||||||
ULONG NumberOfResources = 0;
|
ULONG NumberOfResources = 0;
|
||||||
PCM_RESOURCE_LIST ResourceList;
|
PCM_RESOURCE_LIST ResourceList;
|
||||||
PCM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor;
|
PCM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor;
|
||||||
|
@ -595,7 +594,6 @@ Bus_PDO_QueryResources(
|
||||||
ULONG ResourceListSize;
|
ULONG ResourceListSize;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
|
||||||
|
|
||||||
/* Get current resources */
|
/* Get current resources */
|
||||||
Buffer.Length = 0;
|
Buffer.Length = 0;
|
||||||
AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer);
|
AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer);
|
||||||
|
@ -619,8 +617,7 @@ Bus_PDO_QueryResources(
|
||||||
|
|
||||||
resource= Buffer.Pointer;
|
resource= Buffer.Pointer;
|
||||||
/* Count number of resources */
|
/* Count number of resources */
|
||||||
Done = FALSE;
|
while (resource->Type != ACPI_RESOURCE_TYPE_END_TAG)
|
||||||
while (!Done)
|
|
||||||
{
|
{
|
||||||
switch (resource->Type)
|
switch (resource->Type)
|
||||||
{
|
{
|
||||||
|
@ -641,13 +638,9 @@ Bus_PDO_QueryResources(
|
||||||
NumberOfResources++;
|
NumberOfResources++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ACPI_RESOURCE_TYPE_END_TAG:
|
|
||||||
{
|
|
||||||
Done = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
DPRINT1("Unknown resource type: %d\n", resource->Type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -659,7 +652,10 @@ Bus_PDO_QueryResources(
|
||||||
ResourceList = (PCM_RESOURCE_LIST)ExAllocatePool(PagedPool, ResourceListSize);
|
ResourceList = (PCM_RESOURCE_LIST)ExAllocatePool(PagedPool, ResourceListSize);
|
||||||
|
|
||||||
if (!ResourceList)
|
if (!ResourceList)
|
||||||
return FALSE;
|
{
|
||||||
|
ExFreePool(Buffer.Pointer);
|
||||||
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
}
|
||||||
ResourceList->Count = 1;
|
ResourceList->Count = 1;
|
||||||
ResourceList->List[0].InterfaceType = Internal; /* FIXME */
|
ResourceList->List[0].InterfaceType = Internal; /* FIXME */
|
||||||
ResourceList->List[0].BusNumber = 0; /* We're the only ACPI bus device in the system */
|
ResourceList->List[0].BusNumber = 0; /* We're the only ACPI bus device in the system */
|
||||||
|
@ -669,8 +665,7 @@ Bus_PDO_QueryResources(
|
||||||
ResourceDescriptor = ResourceList->List[0].PartialResourceList.PartialDescriptors;
|
ResourceDescriptor = ResourceList->List[0].PartialResourceList.PartialDescriptors;
|
||||||
|
|
||||||
/* Fill resources list structure */
|
/* Fill resources list structure */
|
||||||
Done = FALSE;
|
while (resource->Type != ACPI_RESOURCE_TYPE_END_TAG)
|
||||||
while (!Done)
|
|
||||||
{
|
{
|
||||||
switch (resource->Type)
|
switch (resource->Type)
|
||||||
{
|
{
|
||||||
|
@ -737,14 +732,8 @@ Bus_PDO_QueryResources(
|
||||||
ResourceDescriptor++;
|
ResourceDescriptor++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ACPI_RESOURCE_TYPE_END_TAG:
|
|
||||||
{
|
|
||||||
Done = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
DPRINT1("Unhandled resource type\n");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -761,7 +750,6 @@ Bus_PDO_QueryResourceRequirements(
|
||||||
PPDO_DEVICE_DATA DeviceData,
|
PPDO_DEVICE_DATA DeviceData,
|
||||||
PIRP Irp )
|
PIRP Irp )
|
||||||
{
|
{
|
||||||
BOOLEAN Done;
|
|
||||||
ULONG NumberOfResources = 0;
|
ULONG NumberOfResources = 0;
|
||||||
ACPI_STATUS AcpiStatus;
|
ACPI_STATUS AcpiStatus;
|
||||||
ACPI_BUFFER Buffer;
|
ACPI_BUFFER Buffer;
|
||||||
|
@ -796,8 +784,7 @@ Bus_PDO_QueryResourceRequirements(
|
||||||
|
|
||||||
resource= Buffer.Pointer;
|
resource= Buffer.Pointer;
|
||||||
/* Count number of resources */
|
/* Count number of resources */
|
||||||
Done = FALSE;
|
while (resource->Type != ACPI_RESOURCE_TYPE_END_TAG)
|
||||||
while (!Done)
|
|
||||||
{
|
{
|
||||||
switch (resource->Type)
|
switch (resource->Type)
|
||||||
{
|
{
|
||||||
|
@ -818,11 +805,6 @@ Bus_PDO_QueryResourceRequirements(
|
||||||
NumberOfResources++;
|
NumberOfResources++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ACPI_RESOURCE_TYPE_END_TAG:
|
|
||||||
{
|
|
||||||
Done = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -837,7 +819,7 @@ Bus_PDO_QueryResourceRequirements(
|
||||||
if (!RequirementsList)
|
if (!RequirementsList)
|
||||||
{
|
{
|
||||||
ExFreePool(Buffer.Pointer);
|
ExFreePool(Buffer.Pointer);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
}
|
}
|
||||||
RequirementsList->ListSize = RequirementsListSize;
|
RequirementsList->ListSize = RequirementsListSize;
|
||||||
RequirementsList->InterfaceType = Internal;
|
RequirementsList->InterfaceType = Internal;
|
||||||
|
@ -850,8 +832,7 @@ Bus_PDO_QueryResourceRequirements(
|
||||||
RequirementDescriptor = RequirementsList->List[0].Descriptors;
|
RequirementDescriptor = RequirementsList->List[0].Descriptors;
|
||||||
|
|
||||||
/* Fill resources list structure */
|
/* Fill resources list structure */
|
||||||
Done = FALSE;
|
while (resource->Type != ACPI_RESOURCE_TYPE_END_TAG)
|
||||||
while (!Done)
|
|
||||||
{
|
{
|
||||||
switch (resource->Type)
|
switch (resource->Type)
|
||||||
{
|
{
|
||||||
|
@ -920,14 +901,8 @@ Bus_PDO_QueryResourceRequirements(
|
||||||
RequirementDescriptor++;
|
RequirementDescriptor++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ACPI_RESOURCE_TYPE_END_TAG:
|
|
||||||
{
|
|
||||||
Done = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
DPRINT1("Unhandled resource type\n");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue