https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d18634c026eeba286699b…
commit d18634c026eeba286699b35a1e10d58c0b0ba4bf
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Thu Feb 18 10:24:53 2021 +0100
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Thu Feb 18 10:24:53 2021 +0100
[NTOS:WMI] Be consistent about potential NULL pointer use
---
ntoskrnl/wmi/wmi.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/ntoskrnl/wmi/wmi.c b/ntoskrnl/wmi/wmi.c
index 7d6d2bb21a8..1b6a70e923f 100644
--- a/ntoskrnl/wmi/wmi.c
+++ b/ntoskrnl/wmi/wmi.c
@@ -108,21 +108,26 @@ NTSTATUS
NTAPI
IoWMIWriteEvent(_Inout_ PVOID WnodeEventItem)
{
- DPRINT1("IoWMIWriteEvent() called for WnodeEventItem %p (Flags = 0x%08lx),
returning success\n",
- WnodeEventItem, ((PWNODE_HEADER)WnodeEventItem)->Flags);
+ PWNODE_HEADER Header = WnodeEventItem;
- if (((PWNODE_HEADER)WnodeEventItem)->Flags & WNODE_FLAG_TRACED_GUID)
+ if(!Header)
{
- DPRINT("IoWMIWriteEvent(): Flags has WNODE_FLAG_TRACED_GUID\n");
+ DPRINT1("Got NULL Item!\n");
+ return STATUS_INVALID_PARAMETER;
+ }
- // Never free WnodeEventItem in this case.
+ DPRINT1("IoWMIWriteEvent() called for WnodeEventItem %p (Flags = 0x%08lx),
returning success\n",
+ WnodeEventItem, Header->Flags);
+ if (Header->Flags & WNODE_FLAG_TRACED_GUID)
+ {
+ // Never free WnodeEventItem in this case.
+ DPRINT("IoWMIWriteEvent(): Flags has WNODE_FLAG_TRACED_GUID\n");
return STATUS_SUCCESS;
}
/* Free the buffer if we are returning success */
- if (WnodeEventItem != NULL)
- ExFreePool(WnodeEventItem);
+ ExFreePool(WnodeEventItem);
return STATUS_SUCCESS;
}
@@ -402,7 +407,7 @@ WmiStartTrace(IN OUT PWMI_LOGGER_INFORMATION LoggerInfo)
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
-
+
NTSTATUS
NTAPI
WmiStopTrace(IN PWMI_LOGGER_INFORMATION LoggerInfo)