]> xenbits.xensource.com Git - pvdrivers/win/xenvif.git/commitdiff
Fix CodeQL warnings
authorOwen Smith <owen.smith@citrix.com>
Thu, 12 Aug 2021 12:44:27 +0000 (13:44 +0100)
committerPaul Durrant <pdurrant@amazon.com>
Mon, 20 Sep 2021 09:55:43 +0000 (10:55 +0100)
- ExAllocatePoolWithTag has been deprecated with Win10 2004, use
    ExAllocatePoolUninitialized instead
- Check return value of _strtoui64 for error condition as indicated by
    _UI64_MAX

Signed-off-by: Owen Smith <owen.smith@citrix.com>
src/xenvif/fdo.c
src/xenvif/mac.c
src/xenvif/pdo.c
src/xenvif/util.h

index 745f94821060aafdee3da49fdbf4403f8a79c8e9..8067e036d81d39de1a5e76a5981848c7af96f071 100644 (file)
@@ -1879,14 +1879,12 @@ FdoQueryDeviceRelations(
 
     Size = FIELD_OFFSET(DEVICE_RELATIONS, Objects) + (sizeof (PDEVICE_OBJECT) * __max(Count, 1));
 
-    Relations = ExAllocatePoolWithTag(PagedPool, Size, 'FIV');
+    Relations = __AllocatePoolWithTag(PagedPool, Size, 'FIV');
 
     status = STATUS_NO_MEMORY;
     if (Relations == NULL)
         goto fail1;
 
-    RtlZeroMemory(Relations, Size);
-
     for (ListEntry = Fdo->Dx->ListEntry.Flink;
          ListEntry != &Fdo->Dx->ListEntry;
          ListEntry = ListEntry->Flink) {
index 82632714e5498350d7bcd2c9d519307ebde8eb8b..606e476b375d3b158c0c207f0df93074d5d01e2b 100644 (file)
@@ -715,6 +715,8 @@ __MacGetSpeed(
         Unit = "G";
     } else {
         Speed = _strtoui64(Buffer, &Unit, 10);
+        if (Speed == _UI64_MAX)
+            Speed = Mac->Speed;
         if (*Unit == '\0')
             Unit = "G";
 
index e6ffbc388d075369a01549d84ec99f15cafb3cdd..bc9b9ed7427a52f723fe320122d6aa2accddc719 100644 (file)
@@ -1595,14 +1595,12 @@ PdoQueryDeviceRelations(
     if (StackLocation->Parameters.QueryDeviceRelations.Type != TargetDeviceRelation)
         goto done;
 
-    Relations = ExAllocatePoolWithTag(PagedPool, sizeof (DEVICE_RELATIONS), 'FIV');
+    Relations = __AllocatePoolWithTag(PagedPool, sizeof (DEVICE_RELATIONS), 'FIV');
 
     status = STATUS_NO_MEMORY;
     if (Relations == NULL)
         goto done;
 
-    RtlZeroMemory(Relations, sizeof (DEVICE_RELATIONS));
-
     Relations->Count = 1;
     ObReferenceObject(__PdoGetDeviceObject(Pdo));
     Relations->Objects[0] = __PdoGetDeviceObject(Pdo);
@@ -1848,14 +1846,12 @@ PdoQueryDeviceText(
         goto done;
     }
 
-    Buffer = ExAllocatePoolWithTag(PagedPool, MAXTEXTLEN, 'FIV');
+    Buffer = __AllocatePoolWithTag(PagedPool, MAXTEXTLEN, 'FIV');
 
     status = STATUS_NO_MEMORY;
     if (Buffer == NULL)
         goto done;
 
-    RtlZeroMemory(Buffer, MAXTEXTLEN);
-
     Text.Buffer = Buffer;
     Text.MaximumLength = MAXTEXTLEN;
     Text.Length = 0;
@@ -1983,14 +1979,12 @@ PdoQueryId(
         goto done;
     }
 
-    Buffer = ExAllocatePoolWithTag(PagedPool, Id.MaximumLength, 'FIV');
+    Buffer = __AllocatePoolWithTag(PagedPool, Id.MaximumLength, 'FIV');
 
     status = STATUS_NO_MEMORY;
     if (Buffer == NULL)
         goto done;
 
-    RtlZeroMemory(Buffer, Id.MaximumLength);
-
     Id.Buffer = Buffer;
     Id.Length = 0;
 
@@ -2129,14 +2123,12 @@ PdoQueryBusInformation(
 
     UNREFERENCED_PARAMETER(Pdo);
 
-    Info = ExAllocatePoolWithTag(PagedPool, sizeof (PNP_BUS_INFORMATION), 'FIV');
+    Info = __AllocatePoolWithTag(PagedPool, sizeof (PNP_BUS_INFORMATION), 'FIV');
 
     status = STATUS_NO_MEMORY;
     if (Info == NULL)
         goto done;
 
-    RtlZeroMemory(Info, sizeof (PNP_BUS_INFORMATION));
-
     Info->BusTypeGuid = GUID_BUS_TYPE_INTERNAL;
     Info->LegacyBusType = PNPBus;
     Info->BusNumber = 0;
index 74d0436038e89ae9e78009bab0597877cd73a935..0df2a52e5ae72ba58302affe5ddab74c55e30444 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;