From 5ba5051f7960b8e2275d0018d1656438a68cf3a0 Mon Sep 17 00:00:00 2001 From: Serge Gautherie Date: Mon, 24 May 2021 08:56:17 +0200 Subject: [PATCH] [FLTMGR] CreateClientPort(): Fix ObInsertObject() error handling Avoid extra ObDereferenceObject(). CORE-17904 --- drivers/filters/fltmgr/Messaging.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/filters/fltmgr/Messaging.c b/drivers/filters/fltmgr/Messaging.c index f4ed276eb4d..713e8fd1770 100644 --- a/drivers/filters/fltmgr/Messaging.c +++ b/drivers/filters/fltmgr/Messaging.c @@ -699,10 +699,12 @@ CreateClientPort(_In_ PFILE_OBJECT FileObject, goto Quit; } - /* Now insert the new client port into the object manager*/ - Status = ObInsertObject(ClientPortObject, 0, FLT_PORT_ALL_ACCESS, 1, 0, (PHANDLE)&PortHandle); + /* Now insert the new client port into the object manager */ + Status = ObInsertObject(ClientPortObject, NULL, FLT_PORT_ALL_ACCESS, 1, NULL, (PHANDLE)&PortHandle); if (!NT_SUCCESS(Status)) { + /* ObInsertObject() failed and already dereferenced ClientPortObject */ + ClientPortObject = NULL; goto Quit; }