Author: cgutman Date: Tue Jul 12 18:18:13 2011 New Revision: 52660
URL: http://svn.reactos.org/svn/reactos?rev=52660&view=rev Log: [NTOSKRNL] - Fix broken handling for duplicate loads in IopLoadUnloadDriver - Fixes duplicate loading messages being displayed during boot and duplicate legacy device nodes being created for the same driver - NOTE: These fixes do not affect drivers loaded by FreeLoader which are handled by a separate function IopInitializeBuiltinDriver
Modified: trunk/reactos/ntoskrnl/io/iomgr/driver.c
Modified: trunk/reactos/ntoskrnl/io/iomgr/driver.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/driver.c?... ============================================================================== --- trunk/reactos/ntoskrnl/io/iomgr/driver.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/iomgr/driver.c [iso-8859-1] Tue Jul 12 18:18:13 2011 @@ -850,7 +850,6 @@ DPRINT1("Driver '%wZ' load failed, status (%x)\n", ModuleName, Status); return(Status); } - DeviceNode->ServiceName = ServiceName;
/* * Initialize the driver @@ -1834,8 +1833,6 @@ cur--; }
- IopDisplayLoadingMessage(&ServiceName); - /* * Get service type. */ @@ -1881,21 +1878,6 @@
DPRINT("FullImagePath: '%wZ'\n", &ImagePath); DPRINT("Type: %lx\n", Type); - - /* - * Create device node - */ - - /* Use IopRootDeviceNode for now */ - Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &ServiceName, &DeviceNode); - - if (!NT_SUCCESS(Status)) - { - DPRINT("IopCreateDeviceNode() failed (Status %lx)\n", Status); - LoadParams->Status = Status; - (VOID)KeSetEvent(&LoadParams->Event, 0, FALSE); - return; - }
/* Get existing DriverObject pointer (in case the driver has already been loaded and initialized) */ @@ -1916,23 +1898,29 @@ if (!NT_SUCCESS(Status) && Status != STATUS_IMAGE_ALREADY_LOADED) { DPRINT("MmLoadSystemImage() failed (Status %lx)\n", Status); - IopFreeDeviceNode(DeviceNode); LoadParams->Status = Status; (VOID)KeSetEvent(&LoadParams->Event, 0, FALSE); return; } - - /* - * Set a service name for the device node - */ - - RtlCreateUnicodeString(&DeviceNode->ServiceName, ServiceName.Buffer);
/* * Initialize the driver module if it's loaded for the first time */ if (Status != STATUS_IMAGE_ALREADY_LOADED) { + Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &ServiceName, &DeviceNode); + + if (!NT_SUCCESS(Status)) + { + DPRINT("IopCreateDeviceNode() failed (Status %lx)\n", Status); + MmUnloadSystemImage(ModuleObject); + LoadParams->Status = Status; + (VOID)KeSetEvent(&LoadParams->Event, 0, FALSE); + return; + } + + IopDisplayLoadingMessage(&DeviceNode->ServiceName); + Status = IopInitializeDriverModule( DeviceNode, ModuleObject, @@ -1950,11 +1938,11 @@ (VOID)KeSetEvent(&LoadParams->Event, 0, FALSE); return; } + + /* Initialize and start device */ + IopInitializeDevice(DeviceNode, DriverObject); + Status = IopStartDevice(DeviceNode); } - - /* Initialize and start device */ - IopInitializeDevice(DeviceNode, DriverObject); - Status = IopStartDevice(DeviceNode); } else { @@ -1962,9 +1950,6 @@
/* IopGetDriverObject references the DriverObject, so dereference it */ ObDereferenceObject(DriverObject); - - /* Free device node since driver loading failed */ - IopFreeDeviceNode(DeviceNode); }
/* Pass status to the caller and signal the event */