mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +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:
parent
6ca9e86d16
commit
f706d2ed15
2 changed files with 13 additions and 14 deletions
|
@ -558,6 +558,7 @@ IopAttachFilterDriversCallback(
|
||||||
Filters += (ServiceName.Length / sizeof(WCHAR)) + 1)
|
Filters += (ServiceName.Length / sizeof(WCHAR)) + 1)
|
||||||
{
|
{
|
||||||
DPRINT("Filter Driver: %S (%wZ)\n", Filters, &DeviceNode->InstancePath);
|
DPRINT("Filter Driver: %S (%wZ)\n", Filters, &DeviceNode->InstancePath);
|
||||||
|
|
||||||
ServiceName.Buffer = Filters;
|
ServiceName.Buffer = Filters;
|
||||||
ServiceName.MaximumLength =
|
ServiceName.MaximumLength =
|
||||||
ServiceName.Length = (USHORT)wcslen(Filters) * sizeof(WCHAR);
|
ServiceName.Length = (USHORT)wcslen(Filters) * sizeof(WCHAR);
|
||||||
|
@ -579,8 +580,9 @@ IopAttachFilterDriversCallback(
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = IopInitializeDevice(DeviceNode, DriverObject);
|
Status = IopInitializeDevice(DeviceNode, DriverObject);
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
continue;
|
/* Remove extra reference */
|
||||||
|
ObDereferenceObject(DriverObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
@ -875,6 +877,9 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry)
|
||||||
Status = IopStartDevice(DeviceNode);
|
Status = IopStartDevice(DeviceNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove extra reference from IopInitializeDriverModule */
|
||||||
|
ObDereferenceObject(DriverObject);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1960,6 +1965,7 @@ IopLoadUnloadDriver(PLOAD_UNLOAD_PARAMS LoadParams)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DPRINT("DriverObject already exist in ObjectManager\n");
|
DPRINT("DriverObject already exist in ObjectManager\n");
|
||||||
|
Status = STATUS_IMAGE_ALREADY_LOADED;
|
||||||
|
|
||||||
/* IopGetDriverObject references the DriverObject, so dereference it */
|
/* IopGetDriverObject references the DriverObject, so dereference it */
|
||||||
ObDereferenceObject(DriverObject);
|
ObDereferenceObject(DriverObject);
|
||||||
|
|
|
@ -2592,19 +2592,9 @@ IopActionInitChildServices(PDEVICE_NODE DeviceNode,
|
||||||
|
|
||||||
if (NT_SUCCESS(Status) || Status == STATUS_IMAGE_ALREADY_LOADED)
|
if (NT_SUCCESS(Status) || Status == STATUS_IMAGE_ALREADY_LOADED)
|
||||||
{
|
{
|
||||||
/* STATUS_IMAGE_ALREADY_LOADED means this driver
|
/* Initialize the driver */
|
||||||
was loaded by the bootloader */
|
Status = IopInitializeDriverModule(DeviceNode, ModuleObject,
|
||||||
if ((Status != STATUS_IMAGE_ALREADY_LOADED) ||
|
|
||||||
(Status == STATUS_IMAGE_ALREADY_LOADED && !DriverObject))
|
|
||||||
{
|
|
||||||
/* Initialize the driver */
|
|
||||||
Status = IopInitializeDriverModule(DeviceNode, ModuleObject,
|
|
||||||
&DeviceNode->ServiceName, FALSE, &DriverObject);
|
&DeviceNode->ServiceName, FALSE, &DriverObject);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Status = STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2618,6 +2608,9 @@ IopActionInitChildServices(PDEVICE_NODE DeviceNode,
|
||||||
{
|
{
|
||||||
/* Initialize the device, including all filters */
|
/* Initialize the device, including all filters */
|
||||||
Status = PipCallDriverAddDevice(DeviceNode, FALSE, DriverObject);
|
Status = PipCallDriverAddDevice(DeviceNode, FALSE, DriverObject);
|
||||||
|
|
||||||
|
/* Remove the extra reference */
|
||||||
|
ObDereferenceObject(DriverObject);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue