[HALX86] HalpDmaAllocateChildAdapter(): Fix memory leak, on error (#4156)

Simplify code, instead of adding 2 missing ObDereferenceObject().
(Note that ObInsertObject() always dereferences the object in case of failure.)

CORE-17904
This commit is contained in:
Serge Gautherie 2021-12-20 21:14:36 +01:00 committed by GitHub
parent 2196a06fc1
commit 0fd3e51580
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -477,12 +477,6 @@ HalpDmaAllocateChildAdapter(IN ULONG NumberOfMapRegisters,
(PVOID)&AdapterObject); (PVOID)&AdapterObject);
if (!NT_SUCCESS(Status)) return NULL; if (!NT_SUCCESS(Status)) return NULL;
Status = ObReferenceObjectByPointer(AdapterObject,
FILE_READ_DATA | FILE_WRITE_DATA,
IoAdapterObjectType,
KernelMode);
if (!NT_SUCCESS(Status)) return NULL;
RtlZeroMemory(AdapterObject, sizeof(ADAPTER_OBJECT)); RtlZeroMemory(AdapterObject, sizeof(ADAPTER_OBJECT));
Status = ObInsertObject(AdapterObject, Status = ObInsertObject(AdapterObject,
@ -493,6 +487,8 @@ HalpDmaAllocateChildAdapter(IN ULONG NumberOfMapRegisters,
&Handle); &Handle);
if (!NT_SUCCESS(Status)) return NULL; if (!NT_SUCCESS(Status)) return NULL;
ObReferenceObject(AdapterObject);
ZwClose(Handle); ZwClose(Handle);
AdapterObject->DmaHeader.Version = (USHORT)DeviceDescription->Version; AdapterObject->DmaHeader.Version = (USHORT)DeviceDescription->Version;