Author: cgutman
Date: Tue Mar 6 21:07:25 2012
New Revision: 56063
URL:
http://svn.reactos.org/svn/reactos?rev=56063&view=rev
Log:
[NTOSKRNL]
- Fix several driver object reference leaks
- Fix a kmtest regarding previously loaded drivers
- Part 1 of getting PnP driver unload to work properly
Modified:
trunk/reactos/ntoskrnl/io/iomgr/driver.c
trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.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 Mar 6 21:07:25 2012
@@ -558,6 +558,7 @@
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 @@
}
Status = IopInitializeDevice(DeviceNode, DriverObject);
- if (!NT_SUCCESS(Status))
- continue;
+
+ /* Remove extra reference */
+ ObDereferenceObject(DriverObject);
}
return STATUS_SUCCESS;
@@ -874,6 +876,9 @@
{
Status = IopStartDevice(DeviceNode);
}
+
+ /* Remove extra reference from IopInitializeDriverModule */
+ ObDereferenceObject(DriverObject);
return Status;
}
@@ -1960,6 +1965,7 @@
else
{
DPRINT("DriverObject already exist in ObjectManager\n");
+ Status = STATUS_IMAGE_ALREADY_LOADED;
/* IopGetDriverObject references the DriverObject, so dereference it */
ObDereferenceObject(DriverObject);
Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.…
==============================================================================
--- trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c [iso-8859-1] Tue Mar 6 21:07:25 2012
@@ -2592,19 +2592,9 @@
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 @@
{
/* Initialize the device, including all filters */
Status = PipCallDriverAddDevice(DeviceNode, FALSE, DriverObject);
+
+ /* Remove the extra reference */
+ ObDereferenceObject(DriverObject);
}
else
{