]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/Mmu: Fix potential page table memory leak
authorHeyi Guo <heyi.guo@linaro.org>
Wed, 9 Sep 2015 13:37:50 +0000 (13:37 +0000)
committerabiesheuvel <abiesheuvel@Edk2>
Wed, 9 Sep 2015 13:37:50 +0000 (13:37 +0000)
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 instead, 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.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
[ardb: move termination condition check inside the loop]
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18425 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c

index 850fe7ff1483639e62514c6a1f3a439c367881a6..df37154f350dd1c0b81153e8749048ff2298b6b2 100644 (file)
@@ -455,6 +455,13 @@ FillTranslationTable (
       RegionStart += BlockEntrySize;\r
       RemainingRegionLength -= BlockEntrySize;\r
       BlockEntry++;\r
+\r
+      // Break the inner loop when next block is a table\r
+      // Rerun GetBlockEntryListFromAddress to avoid page table memory leak\r
+      if (TableLevel != 3 &&\r
+          (*BlockEntry & TT_TYPE_MASK) == TT_TYPE_TABLE_ENTRY) {\r
+            break;\r
+      }\r
     } while ((RemainingRegionLength >= BlockEntrySize) && (BlockEntry <= LastBlockEntry));\r
   } while (RemainingRegionLength != 0);\r
 \r