Skip to content

Commit 3c5d660

Browse files
committed
- 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
1 parent 3d143c0 commit 3c5d660

File tree

2 files changed

+28
-37
lines changed

2 files changed

+28
-37
lines changed

reactos/hal/halx86/generic/acpi/halacpi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ HalpQueryAcpiResourceRequirements(OUT PIO_RESOURCE_REQUIREMENTS_LIST *Requiremen
10021002
else
10031003
{
10041004
/* Fail */
1005-
ExFreePoolWithTag(RequirementsList, 0);
1005+
ExFreePoolWithTag(RequirementsList, ' laH');
10061006
Status = STATUS_NO_SUCH_DEVICE;
10071007
}
10081008
}

reactos/hal/halx86/generic/acpi/halpnpdd.c

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ HalpQueryDeviceRelations(IN PDEVICE_OBJECT DeviceObject,
196196
FdoRelations = ExAllocatePoolWithTag(PagedPool,
197197
FIELD_OFFSET(DEVICE_RELATIONS,
198198
Objects) +
199-
4 * PdoCount,
199+
sizeof(PDEVICE_OBJECT) * PdoCount,
200200
' laH');
201201
if (!FdoRelations) return STATUS_INSUFFICIENT_RESOURCES;
202202

@@ -220,7 +220,7 @@ HalpQueryDeviceRelations(IN PDEVICE_OBJECT DeviceObject,
220220
}
221221

222222
/* Free existing structure */
223-
ExFreePoolWithTag(*DeviceRelations, 0);
223+
ExFreePool(*DeviceRelations);
224224
}
225225

226226
/* Now check if we have a PDO list */
@@ -359,7 +359,7 @@ HalpQueryResources(IN PDEVICE_OBJECT DeviceObject,
359359
{
360360
/* Fail, no memory */
361361
Status = STATUS_INSUFFICIENT_RESOURCES;
362-
ExFreePoolWithTag(RequirementsList, 0);
362+
ExFreePoolWithTag(RequirementsList, ' laH');
363363
return Status;
364364
}
365365

@@ -372,43 +372,40 @@ HalpQueryResources(IN PDEVICE_OBJECT DeviceObject,
372372
ResourceList->List[0].InterfaceType = PNPBus;
373373
ResourceList->List[0].PartialResourceList.Version = 1;
374374
ResourceList->List[0].PartialResourceList.Revision = 1;
375-
ResourceList->List[0].PartialResourceList.Count = 1;
375+
ResourceList->List[0].PartialResourceList.Count = 0;
376376

377377
/* Setup the first descriptor */
378378
PartialDesc = ResourceList->List[0].PartialResourceList.PartialDescriptors;
379-
PartialDesc->Type = CmResourceTypeInterrupt;
380379

381380
/* Find the requirement descriptor for the SCI */
382381
for (i = 0; i < RequirementsList->List[0].Count; i++)
383382
{
384383
/* Get this descriptor */
385384
Descriptor = &RequirementsList->List[0].Descriptors[i];
386-
if (Descriptor->Type == CmResourceTypeInterrupt) break;
387-
Descriptor = NULL;
388-
}
389-
390-
/* Make sure we found the descriptor */
391-
if (Descriptor)
392-
{
393-
/* Copy requirements descriptor into resource descriptor */
394-
PartialDesc->ShareDisposition = Descriptor->ShareDisposition;
395-
PartialDesc->Flags = Descriptor->Flags;
396-
ASSERT(Descriptor->u.Interrupt.MinimumVector ==
397-
Descriptor->u.Interrupt.MaximumVector);
398-
PartialDesc->u.Interrupt.Vector = Descriptor->u.Interrupt.MinimumVector;
399-
PartialDesc->u.Interrupt.Level = Descriptor->u.Interrupt.MinimumVector;
400-
PartialDesc->u.Interrupt.Affinity = 0xFFFFFFFF;
401-
402-
/* Return resources and success */
403-
*Resources = ResourceList;
404-
ExFreePoolWithTag(RequirementsList, 0);
405-
return STATUS_SUCCESS;
385+
if (Descriptor->Type == CmResourceTypeInterrupt)
386+
{
387+
/* Copy requirements descriptor into resource descriptor */
388+
PartialDesc->Type = CmResourceTypeInterrupt;
389+
PartialDesc->ShareDisposition = Descriptor->ShareDisposition;
390+
PartialDesc->Flags = Descriptor->Flags;
391+
ASSERT(Descriptor->u.Interrupt.MinimumVector ==
392+
Descriptor->u.Interrupt.MaximumVector);
393+
PartialDesc->u.Interrupt.Vector = Descriptor->u.Interrupt.MinimumVector;
394+
PartialDesc->u.Interrupt.Level = Descriptor->u.Interrupt.MinimumVector;
395+
PartialDesc->u.Interrupt.Affinity = 0xFFFFFFFF;
396+
397+
ResourceList->List[0].PartialResourceList.Count++;
398+
399+
break;
400+
}
406401
}
407-
408-
/* Free memory and fail */
409-
ExFreePoolWithTag(RequirementsList, 0);
410-
ExFreePoolWithTag(ResourceList, 0);
411-
Status = STATUS_NOT_FOUND;
402+
403+
/* Return resources and success */
404+
*Resources = ResourceList;
405+
406+
ExFreePoolWithTag(RequirementsList, ' laH');
407+
408+
return STATUS_SUCCESS;
412409
}
413410
else if (DeviceExtension->PdoType == WdPdo)
414411
{
@@ -420,9 +417,6 @@ HalpQueryResources(IN PDEVICE_OBJECT DeviceObject,
420417
/* This shouldn't happen */
421418
return STATUS_UNSUCCESSFUL;
422419
}
423-
424-
/* Return the status */
425-
return Status;
426420
}
427421

428422
NTSTATUS
@@ -450,9 +444,6 @@ HalpQueryResourceRequirements(IN PDEVICE_OBJECT DeviceObject,
450444
/* This shouldn't happen */
451445
return STATUS_UNSUCCESSFUL;
452446
}
453-
454-
/* Return the status */
455-
return Status;
456447
}
457448

458449
NTSTATUS

0 commit comments

Comments
 (0)