On 9 September 2015 at 11:53, Heyi Guo <heyi....@linaro.org> 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 <heyi....@linaro.org> > Cc: Leif Lindholm <leif.lindh...@linaro.org> > Cc: Ard Biesheuvel <ard.biesheu...@linaro.org> > --- > 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? > } while (RemainingRegionLength != 0); > > return RETURN_SUCCESS; > -- > 2.5.0 > _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel