https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2abb99faa95ba50a352d690fdfa767c87d59af91

commit 2abb99faa95ba50a352d690fdfa767c87d59af91
Author:     Pierre Schweitzer <[email protected]>
AuthorDate: Sat Jan 20 21:20:11 2018 +0100
Commit:     Pierre Schweitzer <[email protected]>
CommitDate: Sat Jan 20 21:21:00 2018 +0100

    [NTOSKRNL] In FsRtlAddToTunnelCache() allocate memory from PagedPool when 
required.
    Also, if allocating from lookaside list, reattempt a cold allocation.
---
 ntoskrnl/fsrtl/tunnel.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/ntoskrnl/fsrtl/tunnel.c b/ntoskrnl/fsrtl/tunnel.c
index 727f467ddf..545cf2f214 100644
--- a/ntoskrnl/fsrtl/tunnel.c
+++ b/ntoskrnl/fsrtl/tunnel.c
@@ -346,7 +346,7 @@ FsRtlAddToTunnelCache(IN PTUNNEL Cache,
                       IN ULONG DataLength,
                       IN PVOID Data)
 {
-    PTUNNEL_NODE_ENTRY NodeEntry;
+    PTUNNEL_NODE_ENTRY NodeEntry = NULL;
     PRTL_SPLAY_LINKS CurEntry, LastEntry;
     ULONG Length;
     LONG Result = 0;
@@ -384,23 +384,24 @@ FsRtlAddToTunnelCache(IN PTUNNEL Cache,
         Length += LongName->Length;
     }
 
-    if (Length > DEFAULT_ENTRY_SIZE)
-    {
-        /* bigger than default entry */
-        NodeEntry = ExAllocatePool(NonPagedPool, Length);
-        AllocatedFromPool = TRUE;
-    }
-    else
+    if (Length <= DEFAULT_ENTRY_SIZE)
     {
         /* get standard entry */
         NodeEntry = ExAllocateFromPagedLookasideList(&TunnelLookasideList);
     }
 
-    /* check for success */
-    if (!NodeEntry)
+    if (NodeEntry == NULL)
     {
-         /* out of memory */
-         return;
+        /* bigger than default entry or allocation failed */
+        NodeEntry = ExAllocatePool(PagedPool | POOL_COLD_ALLOCATION, Length);
+        /* check for success */
+        if (NodeEntry == NULL)
+        {
+             /* out of memory */
+             return;
+        }
+
+        AllocatedFromPool = TRUE;
     }
 
     /* acquire lock */

Reply via email to