On 09/09/2015 09:38 PM, Ard Biesheuvel wrote:
On 9 September 2015 at 12:35, Ard Biesheuvel <[email protected]> wrote:
On 9 September 2015 at 11:53, Heyi Guo <[email protected]> wrote:
During page entry attribute update, if there are table entries
between starting BlockEntry and LastBlockEntry, table entries will be
set as block entries and the allocated memory of the tables will be
leaked.

so we break the inner loop when we find a table entry and run outer
loop again to step into the table by the same logic.

Another nice find!

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo <[email protected]>
Cc: Leif Lindholm <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
---
  ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c 
b/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c
index 3be6b70..ae1834f 100644
--- a/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c
+++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c
@@ -457,7 +457,11 @@ FillTranslationTable (
        RegionStart += BlockEntrySize;
        RemainingRegionLength -= BlockEntrySize;
        BlockEntry++;
-    } while ((RemainingRegionLength >= BlockEntrySize) && (BlockEntry <= 
LastBlockEntry));
+    // Break the inner loop when next block is a table
+    // Rerun GetBlockEntryListFromAddress to avoid page table memory leak
+    } while ((RemainingRegionLength >= BlockEntrySize) &&
+             (BlockEntry <= LastBlockEntry) &&
+             !(TableLevel != 3 && (*BlockEntry & TT_TYPE_MASK) == 
TT_TYPE_TABLE_ENTRY));
Could we get a 'if (<condition>) break;' inside the loop instead of
folding it into the while() condition?

I fixed this up myself when committing.

Thanks; looks better :)
Heyi


Series committed as SVN r18421 .. r18425

Thanks!


_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to