From df38911464e3e8db43645fe4d1609fef73c7bc06 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Mon, 10 Aug 2009 14:03:01 +0000 Subject: [PATCH] - Rewrite failure branch of IopLoadUnloadDriver to return a real status code instead of always hardcoding it to STATUS_IMAGE_ALREADY_LOADED (r42473) and remove unneeded code duplication. svn path=/trunk/; revision=42592 --- reactos/ntoskrnl/io/iomgr/driver.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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); }