https://git.reactos.org/?p=reactos.git;a=commitdiff;h=32c7c1157d64edd0f2e51…
commit 32c7c1157d64edd0f2e512644e518abfcc372542
Author: Victor Perevertkin <victor.perevertkin(a)reactos.org>
AuthorDate: Tue Sep 8 14:51:20 2020 +0300
Commit: Victor Perevertkin <victor.perevertkin(a)reactos.org>
CommitDate: Tue Sep 8 14:51:20 2020 +0300
[NTOS:IO] Fix a reference leak in IopSynchronousCall on failure case
Co-authored-by: Vadim Galyant <vgal(a)rambler.ru>
---
ntoskrnl/io/pnpmgr/pnpmgr.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/ntoskrnl/io/pnpmgr/pnpmgr.c b/ntoskrnl/io/pnpmgr/pnpmgr.c
index 7ed3eee62a0..ac9d71a9b99 100644
--- a/ntoskrnl/io/pnpmgr/pnpmgr.c
+++ b/ntoskrnl/io/pnpmgr/pnpmgr.c
@@ -563,7 +563,11 @@ IopSynchronousCall(IN PDEVICE_OBJECT DeviceObject,
/* Allocate an IRP */
Irp = IoAllocateIrp(TopDeviceObject->StackSize, FALSE);
- if (!Irp) return STATUS_INSUFFICIENT_RESOURCES;
+ if (!Irp)
+ {
+ ObDereferenceObject(TopDeviceObject);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
/* Initialize to failure */
Irp->IoStatus.Status = IoStatusBlock.Status = STATUS_NOT_SUPPORTED;