mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 21:05:43 +00:00
- Free memory using a valid tag
- Don't use a hardcoded constant for pointer size - Don't access invalid memory when an SCI is absent (fixes ASSERT(Descriptor->u.Interrupt.MinimumVector == Descriptor->u.Interrupt.MaximumVector) failure) - Remove unreachable code svn path=/trunk/; revision=53275
This commit is contained in:
parent
3d143c0ab0
commit
3c5d660a3d
2 changed files with 28 additions and 37 deletions
|
@ -1002,7 +1002,7 @@ HalpQueryAcpiResourceRequirements(OUT PIO_RESOURCE_REQUIREMENTS_LIST *Requiremen
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Fail */
|
/* Fail */
|
||||||
ExFreePoolWithTag(RequirementsList, 0);
|
ExFreePoolWithTag(RequirementsList, ' laH');
|
||||||
Status = STATUS_NO_SUCH_DEVICE;
|
Status = STATUS_NO_SUCH_DEVICE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ HalpQueryDeviceRelations(IN PDEVICE_OBJECT DeviceObject,
|
||||||
FdoRelations = ExAllocatePoolWithTag(PagedPool,
|
FdoRelations = ExAllocatePoolWithTag(PagedPool,
|
||||||
FIELD_OFFSET(DEVICE_RELATIONS,
|
FIELD_OFFSET(DEVICE_RELATIONS,
|
||||||
Objects) +
|
Objects) +
|
||||||
4 * PdoCount,
|
sizeof(PDEVICE_OBJECT) * PdoCount,
|
||||||
' laH');
|
' laH');
|
||||||
if (!FdoRelations) return STATUS_INSUFFICIENT_RESOURCES;
|
if (!FdoRelations) return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ HalpQueryDeviceRelations(IN PDEVICE_OBJECT DeviceObject,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free existing structure */
|
/* Free existing structure */
|
||||||
ExFreePoolWithTag(*DeviceRelations, 0);
|
ExFreePool(*DeviceRelations);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now check if we have a PDO list */
|
/* Now check if we have a PDO list */
|
||||||
|
@ -359,7 +359,7 @@ HalpQueryResources(IN PDEVICE_OBJECT DeviceObject,
|
||||||
{
|
{
|
||||||
/* Fail, no memory */
|
/* Fail, no memory */
|
||||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||||
ExFreePoolWithTag(RequirementsList, 0);
|
ExFreePoolWithTag(RequirementsList, ' laH');
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,43 +372,40 @@ HalpQueryResources(IN PDEVICE_OBJECT DeviceObject,
|
||||||
ResourceList->List[0].InterfaceType = PNPBus;
|
ResourceList->List[0].InterfaceType = PNPBus;
|
||||||
ResourceList->List[0].PartialResourceList.Version = 1;
|
ResourceList->List[0].PartialResourceList.Version = 1;
|
||||||
ResourceList->List[0].PartialResourceList.Revision = 1;
|
ResourceList->List[0].PartialResourceList.Revision = 1;
|
||||||
ResourceList->List[0].PartialResourceList.Count = 1;
|
ResourceList->List[0].PartialResourceList.Count = 0;
|
||||||
|
|
||||||
/* Setup the first descriptor */
|
/* Setup the first descriptor */
|
||||||
PartialDesc = ResourceList->List[0].PartialResourceList.PartialDescriptors;
|
PartialDesc = ResourceList->List[0].PartialResourceList.PartialDescriptors;
|
||||||
PartialDesc->Type = CmResourceTypeInterrupt;
|
|
||||||
|
|
||||||
/* Find the requirement descriptor for the SCI */
|
/* Find the requirement descriptor for the SCI */
|
||||||
for (i = 0; i < RequirementsList->List[0].Count; i++)
|
for (i = 0; i < RequirementsList->List[0].Count; i++)
|
||||||
{
|
{
|
||||||
/* Get this descriptor */
|
/* Get this descriptor */
|
||||||
Descriptor = &RequirementsList->List[0].Descriptors[i];
|
Descriptor = &RequirementsList->List[0].Descriptors[i];
|
||||||
if (Descriptor->Type == CmResourceTypeInterrupt) break;
|
if (Descriptor->Type == CmResourceTypeInterrupt)
|
||||||
Descriptor = NULL;
|
{
|
||||||
|
/* Copy requirements descriptor into resource descriptor */
|
||||||
|
PartialDesc->Type = CmResourceTypeInterrupt;
|
||||||
|
PartialDesc->ShareDisposition = Descriptor->ShareDisposition;
|
||||||
|
PartialDesc->Flags = Descriptor->Flags;
|
||||||
|
ASSERT(Descriptor->u.Interrupt.MinimumVector ==
|
||||||
|
Descriptor->u.Interrupt.MaximumVector);
|
||||||
|
PartialDesc->u.Interrupt.Vector = Descriptor->u.Interrupt.MinimumVector;
|
||||||
|
PartialDesc->u.Interrupt.Level = Descriptor->u.Interrupt.MinimumVector;
|
||||||
|
PartialDesc->u.Interrupt.Affinity = 0xFFFFFFFF;
|
||||||
|
|
||||||
|
ResourceList->List[0].PartialResourceList.Count++;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure we found the descriptor */
|
/* Return resources and success */
|
||||||
if (Descriptor)
|
*Resources = ResourceList;
|
||||||
{
|
|
||||||
/* Copy requirements descriptor into resource descriptor */
|
ExFreePoolWithTag(RequirementsList, ' laH');
|
||||||
PartialDesc->ShareDisposition = Descriptor->ShareDisposition;
|
|
||||||
PartialDesc->Flags = Descriptor->Flags;
|
return STATUS_SUCCESS;
|
||||||
ASSERT(Descriptor->u.Interrupt.MinimumVector ==
|
|
||||||
Descriptor->u.Interrupt.MaximumVector);
|
|
||||||
PartialDesc->u.Interrupt.Vector = Descriptor->u.Interrupt.MinimumVector;
|
|
||||||
PartialDesc->u.Interrupt.Level = Descriptor->u.Interrupt.MinimumVector;
|
|
||||||
PartialDesc->u.Interrupt.Affinity = 0xFFFFFFFF;
|
|
||||||
|
|
||||||
/* Return resources and success */
|
|
||||||
*Resources = ResourceList;
|
|
||||||
ExFreePoolWithTag(RequirementsList, 0);
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free memory and fail */
|
|
||||||
ExFreePoolWithTag(RequirementsList, 0);
|
|
||||||
ExFreePoolWithTag(ResourceList, 0);
|
|
||||||
Status = STATUS_NOT_FOUND;
|
|
||||||
}
|
}
|
||||||
else if (DeviceExtension->PdoType == WdPdo)
|
else if (DeviceExtension->PdoType == WdPdo)
|
||||||
{
|
{
|
||||||
|
@ -420,9 +417,6 @@ HalpQueryResources(IN PDEVICE_OBJECT DeviceObject,
|
||||||
/* This shouldn't happen */
|
/* This shouldn't happen */
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the status */
|
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -450,9 +444,6 @@ HalpQueryResourceRequirements(IN PDEVICE_OBJECT DeviceObject,
|
||||||
/* This shouldn't happen */
|
/* This shouldn't happen */
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the status */
|
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue