[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/3] Fix CodeQL warnings


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Thu, 12 Aug 2021 13:39:07 +0100
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Owen Smith <owen.smith@xxxxxxxxxx>
  • Delivery-date: Thu, 12 Aug 2021 12:39:17 +0000
  • Ironport-hdrordr: A9a23:cDfRBqtgXlaYjvfi7rF8hrNU7skDcNV00zEX/kB9WHVpmszxra +TdZMgpHjJYVcqKQgdcL+7WZVoLUmwyXcx2/hyAV7AZniDhILLFuFfBOLZqlWKcREWtNQtsJ uIG5IObuEYZmIVsS+V2mWF+q4bsbq6zJw=
  • Ironport-sdr: bZv4kNQTMWp6enJUqY45gs+qFv9ZJ1f2LjT4rP+II+Ztlxkt+PJe+GrMikPDp4dPy69T9u+aAW x74n6PbOJv4s/hvEfZ4jUToVYNRdROa2iopEnGXvmzjkzd3URKuRk2YIxmI1ZGMJXvC8F0eQy8 mhBORZkXG+f8vocEkEvibiBL21ceWJtgPtpn7YGBrLvLGKXrck5Ma+Dk1FHuv7st4aVgtC9CbG 8NEK5zW3YLHug3xKkYP9FBqUei7zinE56TBgB60rHbmVKgo8LiSTmNyTrZjx7lsAD+3V4cSwdn 6C2b7c5u5CtVBmdOYPvmRG8U
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

- ExAllocatePoolWithTag is deprecated in Win10 2004, use
    ExAllocatePoolUninitialized instead
- QueryCapabilities structure contains padding bytes, using
    __AllocatePoolWithTag zeros this memory

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/xennet/driver.c      | 3 ++-
 src/xennet/receiver.c    | 4 ++--
 src/xennet/transmitter.c | 5 +++--
 src/xennet/util.h        | 4 ++++
 4 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/xennet/driver.c b/src/xennet/driver.c
index 20f1d0e..8127621 100644
--- a/src/xennet/driver.c
+++ b/src/xennet/driver.c
@@ -37,6 +37,7 @@
 #include "miniport.h"
 #include "dbg_print.h"
 #include "assert.h"
+#include "util.h"
 
 typedef struct _XENNET_DRIVER {
     NDIS_HANDLE MiniportHandle;
@@ -93,7 +94,7 @@ QueryCapabilities(
 
     StackLocation = IoGetCurrentIrpStackLocation(Irp);
 
-    Context = ExAllocatePoolWithTag(NonPagedPool, sizeof (XENNET_CONTEXT), ' 
TEN');
+    Context = __AllocatePoolWithTag(NonPagedPool, sizeof (XENNET_CONTEXT), ' 
TEN');
     if (Context != NULL) {
         Context->Capabilities = 
StackLocation->Parameters.DeviceCapabilities.Capabilities;
         Context->CompletionRoutine = StackLocation->CompletionRoutine;
diff --git a/src/xennet/receiver.c b/src/xennet/receiver.c
index ff9a7c5..b46d250 100644
--- a/src/xennet/receiver.c
+++ b/src/xennet/receiver.c
@@ -435,7 +435,7 @@ ReceiverInitialize(
     ULONG                           Index;
     NDIS_STATUS                     status;
 
-    *Receiver = ExAllocatePoolWithTag(NonPagedPool,
+    *Receiver = __AllocatePoolWithTag(NonPagedPool,
                                       sizeof(XENNET_RECEIVER),
                                       RECEIVER_POOL_TAG);
 
@@ -519,7 +519,7 @@ ReceiverTeardown(
 
     Receiver->Adapter = NULL;
 
-    ExFreePoolWithTag(Receiver, RECEIVER_POOL_TAG);
+    __FreePoolWithTag(Receiver, RECEIVER_POOL_TAG);
 }
 
 VOID
diff --git a/src/xennet/transmitter.c b/src/xennet/transmitter.c
index 334bbb9..c962814 100644
--- a/src/xennet/transmitter.c
+++ b/src/xennet/transmitter.c
@@ -36,6 +36,7 @@
 #include <tcpip.h>
 #include "dbg_print.h"
 #include "assert.h"
+#include "util.h"
 
 struct _XENNET_TRANSMITTER {
     PXENNET_ADAPTER             Adapter;
@@ -53,7 +54,7 @@ TransmitterInitialize (
 {
     NTSTATUS                status;
 
-    *Transmitter = ExAllocatePoolWithTag(NonPagedPool,
+    *Transmitter = __AllocatePoolWithTag(NonPagedPool,
                                          sizeof(XENNET_TRANSMITTER),
                                          TRANSMITTER_POOL_TAG);
 
@@ -85,7 +86,7 @@ TransmitterTeardown(
 
     RtlZeroMemory(&Transmitter->Lock, sizeof(KSPIN_LOCK));
 
-    ExFreePoolWithTag(Transmitter, TRANSMITTER_POOL_TAG);
+    __FreePoolWithTag(Transmitter, TRANSMITTER_POOL_TAG);
 }
 
 typedef struct _NET_BUFFER_LIST_RESERVED {
diff --git a/src/xennet/util.h b/src/xennet/util.h
index 9a9a8ff..8ef6097 100644
--- a/src/xennet/util.h
+++ b/src/xennet/util.h
@@ -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;
 
-- 
2.31.1.windows.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.