mirror of
https://github.com/reactos/reactos.git
synced 2024-10-06 09:24:11 +00:00
Never call driver AddDevice routine with a NULL PDO
svn path=/trunk/; revision=27412
This commit is contained in:
parent
a10da52c02
commit
a6fa0638e6
|
@ -80,39 +80,43 @@ IopInitializeDevice(PDEVICE_NODE DeviceNode,
|
|||
{
|
||||
PDEVICE_OBJECT Fdo;
|
||||
NTSTATUS Status;
|
||||
BOOLEAN IsPnpDriver = FALSE;
|
||||
|
||||
if (DriverObject->DriverExtension->AddDevice)
|
||||
{
|
||||
if (!DriverObject->DriverExtension->AddDevice)
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
/* This is a Plug and Play driver */
|
||||
DPRINT("Plug and Play driver found\n");
|
||||
|
||||
ASSERT(DeviceNode->PhysicalDeviceObject);
|
||||
|
||||
DPRINT("Calling driver AddDevice entrypoint at %08lx\n",
|
||||
DriverObject->DriverExtension->AddDevice);
|
||||
/* Check if this plug-and-play driver is used as a legacy one for this device node */
|
||||
if (IopDeviceNodeHasFlag(DeviceNode, DNF_LEGACY_DRIVER))
|
||||
{
|
||||
IopDeviceNodeSetFlag(DeviceNode, DNF_ADDED);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
IsPnpDriver = !IopDeviceNodeHasFlag(DeviceNode, DNF_LEGACY_DRIVER);
|
||||
DPRINT("Calling %wZ->AddDevice(%wZ)\n",
|
||||
&DriverObject->DriverName,
|
||||
&DeviceNode->InstancePath);
|
||||
Status = DriverObject->DriverExtension->AddDevice(
|
||||
DriverObject, IsPnpDriver ? DeviceNode->PhysicalDeviceObject : NULL);
|
||||
|
||||
DriverObject, DeviceNode->PhysicalDeviceObject);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
IopDeviceNodeSetFlag(DeviceNode, DNF_DISABLED);
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (IsPnpDriver)
|
||||
{
|
||||
/* Check if driver added a FDO above the PDO */
|
||||
Fdo = IoGetAttachedDeviceReference(DeviceNode->PhysicalDeviceObject);
|
||||
|
||||
if (Fdo == DeviceNode->PhysicalDeviceObject)
|
||||
{
|
||||
/* FIXME: What do we do? Unload the driver or just disable the device? */
|
||||
DbgPrint("An FDO was not attached\n");
|
||||
DPRINT1("An FDO was not attached\n");
|
||||
IopDeviceNodeSetFlag(DeviceNode, DNF_DISABLED);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
/* Check if we have a ACPI device (needed for power management) */
|
||||
if (Fdo->DeviceType == FILE_DEVICE_ACPI)
|
||||
{
|
||||
static BOOLEAN SystemPowerDeviceNodeCreated = FALSE;
|
||||
|
@ -121,16 +125,15 @@ IopInitializeDevice(PDEVICE_NODE DeviceNode,
|
|||
if (!SystemPowerDeviceNodeCreated)
|
||||
{
|
||||
PopSystemPowerDeviceNode = DeviceNode;
|
||||
ObReferenceObject(PopSystemPowerDeviceNode);
|
||||
SystemPowerDeviceNodeCreated = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
ObDereferenceObject(Fdo);
|
||||
}
|
||||
|
||||
IopDeviceNodeSetFlag(DeviceNode, DNF_ADDED);
|
||||
IopDeviceNodeSetFlag(DeviceNode, DNF_NEED_ENUMERATION_ONLY);
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue