[NTOS:WMI] Be consistent about potential NULL pointer use

This commit is contained in:
Jérôme Gardou 2021-02-18 10:24:53 +01:00
parent 17a9041da1
commit d18634c026

View file

@ -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;
}
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)