diff --git a/reactos/ntoskrnl/io/iomgr/driver.c b/reactos/ntoskrnl/io/iomgr/driver.c index dea9035e11a..f314a411a6c 100644 --- a/reactos/ntoskrnl/io/iomgr/driver.c +++ b/reactos/ntoskrnl/io/iomgr/driver.c @@ -1775,20 +1775,24 @@ IopLoadUnloadDriver(PLOAD_UNLOAD_PARAMS LoadParams) /* Store its DriverSection, so that it could be unloaded */ DriverObject->DriverSection = ModuleObject; + + /* Initialize and start device */ + IopInitializeDevice(DeviceNode, DriverObject); + Status = IopStartDevice(DeviceNode); } else { DPRINT("DriverObject already exist in ObjectManager\n"); - /* IopGetDriverObject references the DriverObject, so dereference it. */ + + /* IopGetDriverObject references the DriverObject, so dereference it */ ObDereferenceObject(DriverObject); + + /* Free device node since driver loading failed */ IopFreeDeviceNode(DeviceNode); - LoadParams->Status = STATUS_IMAGE_ALREADY_LOADED; - (VOID)KeSetEvent(&LoadParams->Event, 0, FALSE); - return; } - IopInitializeDevice(DeviceNode, DriverObject); - LoadParams->Status = IopStartDevice(DeviceNode); + /* Pass status to the caller and signal the event */ + LoadParams->Status = Status; (VOID)KeSetEvent(&LoadParams->Event, 0, FALSE); }