NewNode is the node we found, while Node is the last node in the
list. Also update mFreedBufferSize.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo <heyi....@linaro.org>
Cc: Leif Lindholm <leif.lindh...@linaro.org>
Cc: Ard Biesheuvel <ard.biesheu...@linaro.org>
---
 .../UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c      | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git 
a/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c 
b/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c
index e70d877..b859f63 100644
--- a/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c
+++ b/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c
@@ -125,9 +125,10 @@ AllocatePagesFromList (
   }
   // Check if we have found a node that could contain our new allocation
   if (NewNode != NULL) {
-    NewNode->Allocated = TRUE;
-    Node->Allocation   = (VOID*)(UINTN)Node->Base;
-    *Allocation        = Node->Allocation;
+    NewNode->Allocated  = TRUE;
+    NewNode->Allocation = (VOID*)(UINTN)NewNode->Base;
+    *Allocation         = NewNode->Allocation;
+    mFreedBufferSize    -= NewNode->Pages * EFI_PAGE_SIZE;
     return EFI_SUCCESS;
   }
 
-- 
2.1.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to