[NTOS:PNP] Fix crash when removing a device without resources
authorHervé Poussineau <hpoussin@reactos.org>
Sun, 17 Oct 2021 21:41:27 +0000 (23:41 +0200)
committerHervé Poussineau <hpoussin@reactos.org>
Mon, 18 Oct 2021 20:23:49 +0000 (22:23 +0200)
This fixes commit 89fd2b86e4e1013269961a30c3f1135342df08c9

ntoskrnl/io/pnpmgr/devaction.c

index e9caa76..2126d31 100644 (file)
@@ -1652,9 +1652,13 @@ IopSendRemoveDevice(IN PDEVICE_OBJECT DeviceObject)
     PiIrpSendRemoveCheckVpb(DeviceObject, IRP_MN_REMOVE_DEVICE);
 
     /* Start of HACK: update resources stored in registry, so IopDetectResourceConflict works */
-    DeviceNode->ResourceList->Count = 0;
-    DeviceNode->ResourceListTranslated->Count = 0;
-    IopUpdateResourceMapForPnPDevice(DeviceNode);
+    if (DeviceNode->ResourceList)
+    {
+        ASSERT(DeviceNode->ResourceListTranslated);
+        DeviceNode->ResourceList->Count = 0;
+        DeviceNode->ResourceListTranslated->Count = 0;
+        IopUpdateResourceMapForPnPDevice(DeviceNode);
+    }
     /* End of HACK */
 
     PiSetDevNodeState(DeviceNode, DeviceNodeRemoved);