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

[win-pv-devel] [PATCH] Fix a couple of issues picked up by Windows 10 verifier



- It's possible for MmAllocatePagesForMdlEx() not to satisfy the
  full allocation request, but not fail. Thus AllocatePage() should
  check that the completed allocation actually matches what it
  asks for.

- RegistryCreateKey() has a memory leak.

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 src/xenvif/registry.c |  2 ++
 src/xenvif/util.h     | 10 ++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/xenvif/registry.c b/src/xenvif/registry.c
index 233569f..fb05691 100644
--- a/src/xenvif/registry.c
+++ b/src/xenvif/registry.c
@@ -232,6 +232,8 @@ RegistryCreateKey(
 
     *Key = Child;
 
+    __RegistryFree(Buffer);
+
     return STATUS_SUCCESS;
 
 fail4:
diff --git a/src/xenvif/util.h b/src/xenvif/util.h
index 81dfb49..bb12c89 100644
--- a/src/xenvif/util.h
+++ b/src/xenvif/util.h
@@ -190,12 +190,15 @@ __AllocatePage(
                                   SkipBytes,
                                   TotalBytes,
                                   MmCached,
-                                  0);
+                                  MM_DONT_ZERO_ALLOCATION);
 
     status = STATUS_NO_MEMORY;
     if (Mdl == NULL)
         goto fail1;
 
+    if (Mdl->ByteCount < PAGE_SIZE)
+        goto fail2;
+
     ASSERT((Mdl->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA |
                              MDL_PARTIAL_HAS_BEEN_MAPPED |
                              MDL_PARTIAL |
@@ -212,7 +215,7 @@ __AllocatePage(
 
     status = STATUS_UNSUCCESSFUL;
     if (MdlMappedSystemVa == NULL)
-        goto fail2;
+        goto fail3;
 
     ASSERT3P(MdlMappedSystemVa, ==, Mdl->MappedSystemVa);
 
@@ -220,6 +223,9 @@ __AllocatePage(
 
     return Mdl;
 
+fail3:
+    Error("fail3\n");
+
 fail2:
     Error("fail2\n");
 
-- 
2.5.3


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel

 


Rackspace

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