mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-02 04:13:34 +00:00
[NTOSKRNL]
- Fix several driver object reference leaks - Fix a kmtest regarding previously loaded drivers - Part 1 of getting PnP driver unload to work properly svn path=/trunk/; revision=56063
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user