]> xenbits.xensource.com Git - pvdrivers/win/xenvbd.git/commitdiff
Fix CodeQL warnings
authorOwen Smith <owen.smith@citrix.com>
Thu, 12 Aug 2021 12:41:37 +0000 (13:41 +0100)
committerPaul Durrant <pdurrant@amazon.com>
Mon, 20 Sep 2021 09:32:03 +0000 (10:32 +0100)
- ExAllocatePoolWithTag is deprecated in Win10 2004, use
    ExAllocatePoolUninitialized instead

Signed-off-by: Owen Smith <owen.smith@citrix.com>
src/common/util.h
src/xenvbd/adapter.c
src/xenvbd/base64.c

index eddad4a8ea374d3f8873f0d57f75e173fd537309..36a36dd639ec61ab11ef3698521ade604d8f4778 100644 (file)
@@ -151,8 +151,12 @@ __AllocatePoolWithTag(
     __analysis_assume(PoolType == NonPagedPool ||
                       PoolType == PagedPool);
 
+#if (_MSC_VER >= 1928) // VS 16.9 (EWDK 20344 or later)
+    Buffer = ExAllocatePoolUninitialized(PoolType, NumberOfBytes, Tag);
+#else
 #pragma warning(suppress:28160) // annotation error
     Buffer = ExAllocatePoolWithTag(PoolType, NumberOfBytes, Tag);
+#endif
     if (Buffer == NULL)
         return NULL;
 
index 9fd2abc44d73dfa9b3c6a4d63a8bac7245001ad3..5b17a6b317249a55f802de3823453227e5273680 100644 (file)
@@ -102,13 +102,9 @@ __AdapterAllocate(
     IN  ULONG   Size
     )
 {
-    PVOID       Buffer;
-    Buffer = ExAllocatePoolWithTag(NonPagedPool,
-                                   Size,
-                                   ADAPTER_POOL_TAG);
-    if (Buffer)
-        RtlZeroMemory(Buffer, Size);
-    return Buffer;
+    return __AllocatePoolWithTag(NonPagedPool,
+                                 Size,
+                                 ADAPTER_POOL_TAG);
 }
 
 static FORCEINLINE VOID
@@ -116,7 +112,7 @@ __AdapterFree(
     IN  PVOID   Buffer
     )
 {
-    ExFreePoolWithTag(Buffer, ADAPTER_POOL_TAG);
+    __FreePoolWithTag(Buffer, ADAPTER_POOL_TAG);
 }
 
 static FORCEINLINE PANSI_STRING
index 0e62784e4e5c340a8463790a7ef5bfa396219948..223579a495283b5aa26d94dc2dff6b96980e90b6 100644 (file)
@@ -44,15 +44,9 @@ Base64Allocate(
     IN  ULONG   Size
     )
 {
-    PVOID       Buffer;
-
-    Buffer = ExAllocatePoolWithTag(NonPagedPool,
-                                   Size,
-                                   BASE64_POOL_TAG);
-    if (Buffer)
-        RtlZeroMemory(Buffer, Size);
-
-    return Buffer;
+    return __AllocatePoolWithTag(NonPagedPool,
+                                 Size,
+                                 BASE64_POOL_TAG);
 }
 
 VOID
@@ -60,8 +54,7 @@ Base64Free(
     IN  PVOID   Buffer
     )
 {
-    if (Buffer)
-        ExFreePoolWithTag(Buffer, BASE64_POOL_TAG);
+    __FreePoolWithTag(Buffer, BASE64_POOL_TAG);
 }
 
 static FORCEINLINE UCHAR