diff --git a/reactos/ntoskrnl/io/iomgr/driver.c b/reactos/ntoskrnl/io/iomgr/driver.c index 84eabef6dfb..a500c3a73b5 100644 --- a/reactos/ntoskrnl/io/iomgr/driver.c +++ b/reactos/ntoskrnl/io/iomgr/driver.c @@ -558,6 +558,7 @@ IopAttachFilterDriversCallback( Filters += (ServiceName.Length / sizeof(WCHAR)) + 1) { DPRINT("Filter Driver: %S (%wZ)\n", Filters, &DeviceNode->InstancePath); + ServiceName.Buffer = Filters; ServiceName.MaximumLength = ServiceName.Length = (USHORT)wcslen(Filters) * sizeof(WCHAR); @@ -579,8 +580,9 @@ IopAttachFilterDriversCallback( } Status = IopInitializeDevice(DeviceNode, DriverObject); - if (!NT_SUCCESS(Status)) - continue; + + /* Remove extra reference */ + ObDereferenceObject(DriverObject); } return STATUS_SUCCESS; @@ -875,6 +877,9 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry) Status = IopStartDevice(DeviceNode); } + /* Remove extra reference from IopInitializeDriverModule */ + ObDereferenceObject(DriverObject); + return Status; } @@ -1960,6 +1965,7 @@ IopLoadUnloadDriver(PLOAD_UNLOAD_PARAMS LoadParams) else { DPRINT("DriverObject already exist in ObjectManager\n"); + Status = STATUS_IMAGE_ALREADY_LOADED; /* IopGetDriverObject references the DriverObject, so dereference it */ ObDereferenceObject(DriverObject); diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index 3142dbac57d..16bc2ecd212 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -2592,19 +2592,9 @@ IopActionInitChildServices(PDEVICE_NODE DeviceNode, if (NT_SUCCESS(Status) || Status == STATUS_IMAGE_ALREADY_LOADED) { - /* STATUS_IMAGE_ALREADY_LOADED means this driver - was loaded by the bootloader */ - if ((Status != STATUS_IMAGE_ALREADY_LOADED) || - (Status == STATUS_IMAGE_ALREADY_LOADED && !DriverObject)) - { - /* Initialize the driver */ - Status = IopInitializeDriverModule(DeviceNode, ModuleObject, + /* Initialize the driver */ + Status = IopInitializeDriverModule(DeviceNode, ModuleObject, &DeviceNode->ServiceName, FALSE, &DriverObject); - } - else - { - Status = STATUS_SUCCESS; - } } else { @@ -2618,6 +2608,9 @@ IopActionInitChildServices(PDEVICE_NODE DeviceNode, { /* Initialize the device, including all filters */ Status = PipCallDriverAddDevice(DeviceNode, FALSE, DriverObject); + + /* Remove the extra reference */ + ObDereferenceObject(DriverObject); } else {