[PCI] Fix PDO removal

We must not do anything on PDO removal, especially not deleting it.
We are allowed to delete it, only once we successfully completed a IRP_MN_QUERY_DEVICE_RELATIONS without with PDO.
This commit is contained in:
Hervé Poussineau 2020-06-18 18:18:13 +02:00
parent ea4af587a9
commit 2b9941e7cb

View file

@ -1577,34 +1577,11 @@ PdoPnpControl(
case IRP_MN_STOP_DEVICE:
case IRP_MN_QUERY_REMOVE_DEVICE:
case IRP_MN_CANCEL_REMOVE_DEVICE:
case IRP_MN_REMOVE_DEVICE:
case IRP_MN_SURPRISE_REMOVAL:
Status = STATUS_SUCCESS;
break;
case IRP_MN_REMOVE_DEVICE:
{
PPDO_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
PFDO_DEVICE_EXTENSION FdoDeviceExtension = DeviceExtension->Fdo->DeviceExtension;
KIRQL OldIrql;
/* Remove it from the device list */
KeAcquireSpinLock(&FdoDeviceExtension->DeviceListLock, &OldIrql);
RemoveEntryList(&DeviceExtension->PciDevice->ListEntry);
FdoDeviceExtension->DeviceListCount--;
KeReleaseSpinLock(&FdoDeviceExtension->DeviceListLock, OldIrql);
/* Free the device */
ExFreePoolWithTag(DeviceExtension->PciDevice, TAG_PCI);
/* Complete the IRP */
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
/* Delete the DO */
IoDeleteDevice(DeviceObject);
return STATUS_SUCCESS;
}
case IRP_MN_QUERY_INTERFACE:
DPRINT("IRP_MN_QUERY_INTERFACE received\n");
Status = PdoQueryInterface(DeviceObject, Irp, IrpSp);