https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0fd3e515808e6c0cc4dd2…
commit 0fd3e515808e6c0cc4dd2c662133aeb6e3f9e7b2
Author: Serge Gautherie <32623169+SergeGautherie(a)users.noreply.github.com>
AuthorDate: Mon Dec 20 21:14:36 2021 +0100
Commit: GitHub <noreply(a)github.com>
CommitDate: Mon Dec 20 21:14:36 2021 +0100
[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
---
hal/halx86/generic/dma.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/hal/halx86/generic/dma.c b/hal/halx86/generic/dma.c
index 19d70517b5f..2966a5b2983 100644
--- a/hal/halx86/generic/dma.c
+++ b/hal/halx86/generic/dma.c
@@ -477,12 +477,6 @@ HalpDmaAllocateChildAdapter(IN ULONG NumberOfMapRegisters,
(PVOID)&AdapterObject);
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));
Status = ObInsertObject(AdapterObject,
@@ -493,6 +487,8 @@ HalpDmaAllocateChildAdapter(IN ULONG NumberOfMapRegisters,
&Handle);
if (!NT_SUCCESS(Status)) return NULL;
+ ObReferenceObject(AdapterObject);
+
ZwClose(Handle);
AdapterObject->DmaHeader.Version = (USHORT)DeviceDescription->Version;