driver: switch to MS-recommended memory alloc

Suggested-by: Static Driver Verifier
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2021-07-13 10:20:21 +02:00
parent dccf2085cb
commit 928f21c573
2 changed files with 5 additions and 3 deletions

View File

@ -89,7 +89,7 @@
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup> <ItemDefinitionGroup>
<ClCompile> <ClCompile>
<PreprocessorDefinitions>NDIS_MINIPORT_DRIVER=1;NDIS620_MINIPORT=1;NDIS683_MINIPORT=1;NDIS_WDM=1;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDIS_MINIPORT_DRIVER=1;NDIS620_MINIPORT=1;NDIS683_MINIPORT=1;NDIS_WDM=1;POOL_ZERO_DOWN_LEVEL_SUPPORT;POOL_NX_OPTIN=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalOptions>/volatile:iso %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions>/volatile:iso %(AdditionalOptions)</AdditionalOptions>
<EnablePREfast>true</EnablePREfast> <EnablePREfast>true</EnablePREfast>
</ClCompile> </ClCompile>

View File

@ -988,10 +988,10 @@ TunInitializeEx(
/* Leaking memory 'Ctx'. Note: 'Ctx' is freed in TunHaltEx or on failure. */ /* Leaking memory 'Ctx'. Note: 'Ctx' is freed in TunHaltEx or on failure. */
#pragma warning(suppress : 6014) #pragma warning(suppress : 6014)
TUN_CTX *Ctx = ExAllocatePoolWithTag(NonPagedPoolNx, sizeof(*Ctx), TUN_MEMORY_TAG); #pragma warning(suppress : 28160)
TUN_CTX *Ctx = ExAllocatePoolZero(NonPagedPool, sizeof(*Ctx), TUN_MEMORY_TAG);
if (!Ctx) if (!Ctx)
return NDIS_STATUS_FAILURE; return NDIS_STATUS_FAILURE;
NdisZeroMemory(Ctx, sizeof(*Ctx));
Ctx->MiniportAdapterHandle = MiniportAdapterHandle; Ctx->MiniportAdapterHandle = MiniportAdapterHandle;
@ -1420,6 +1420,8 @@ DriverEntry(DRIVER_OBJECT *DriverObject, UNICODE_STRING *RegistryPath)
{ {
NTSTATUS Status; NTSTATUS Status;
ExInitializeDriverRuntime(DrvRtPoolNxOptIn);
NdisVersion = NdisGetVersion(); NdisVersion = NdisGetVersion();
if (NdisVersion < NDIS_MINIPORT_VERSION_MIN) if (NdisVersion < NDIS_MINIPORT_VERSION_MIN)
return NDIS_STATUS_UNSUPPORTED_REVISION; return NDIS_STATUS_UNSUPPORTED_REVISION;