https://git.reactos.org/?p=reactos.git;a=commitdiff;h=29a706fc5ad0a1b169688b...
commit 29a706fc5ad0a1b169688b86d19f12ef1552c07a Author: Sophie Lemos slemos@fastmail.com AuthorDate: Fri May 26 17:42:36 2023 +0100 Commit: Stanislav Motylkov x86corez@gmail.com CommitDate: Sun Jun 11 13:13:11 2023 +0300
[NTOS:PNP] Fix bug causing all devices be considered as already existing
We should compare against DeviceObject as DeviceInstance is never NULL. Fix a resource leak as well. The bug CORE-18983 seems to lay somewhere else though, I just stumbled upon this one while researching it.
Note there is a BSOD in the PnP manager on reboot after the driver installation failure, but it seems it was uncovered by the fix as opposed to caused by it. --- ntoskrnl/io/pnpmgr/plugplay.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/ntoskrnl/io/pnpmgr/plugplay.c b/ntoskrnl/io/pnpmgr/plugplay.c index 46585458b84..461328c8651 100644 --- a/ntoskrnl/io/pnpmgr/plugplay.c +++ b/ntoskrnl/io/pnpmgr/plugplay.c @@ -218,15 +218,14 @@ IopInitializeDevice(
/* Leave, if the device already exists */ DeviceObject = IopGetDeviceObjectFromDeviceInstance(&DeviceInstance); - if (DeviceInstance.Buffer != NULL) + if (DeviceObject != NULL) { DPRINT1("Device %wZ already exists!\n", &DeviceInstance); + ObDereferenceObject(DeviceObject); Status = STATUS_SUCCESS; goto done; }
- ObDereferenceObject(DeviceObject); - DPRINT("Device %wZ does not exist!\n", &DeviceInstance);
/* Create a device node for the device instance */