Skip to content
Snippets Groups Projects
Commit 12c2ab09 authored by Will Deacon's avatar Will Deacon
Browse files

iommu/io-pgtable-arm: Ensure we free the final level on teardown


When tearing down page tables, we return early for the final level
since we know that we won't have any table pointers to follow.
Unfortunately, this also means that we forget to free the final level,
so we end up leaking memory.

Fix the issue by always freeing the current level, but just don't bother
to iterate over the ptes if we're at the final level.

Cc: <stable@vger.kernel.org>
Reported-by: default avatarZhang Bo <zhangbo_a@xiaomi.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent 6380be05
No related branches found
No related tags found
No related merge requests found
...@@ -404,16 +404,17 @@ static void __arm_lpae_free_pgtable(struct arm_lpae_io_pgtable *data, int lvl, ...@@ -404,16 +404,17 @@ static void __arm_lpae_free_pgtable(struct arm_lpae_io_pgtable *data, int lvl,
arm_lpae_iopte *start, *end; arm_lpae_iopte *start, *end;
unsigned long table_size; unsigned long table_size;
/* Only leaf entries at the last level */
if (lvl == ARM_LPAE_MAX_LEVELS - 1)
return;
if (lvl == ARM_LPAE_START_LVL(data)) if (lvl == ARM_LPAE_START_LVL(data))
table_size = data->pgd_size; table_size = data->pgd_size;
else else
table_size = ARM_LPAE_GRANULE(data); table_size = ARM_LPAE_GRANULE(data);
start = ptep; start = ptep;
/* Only leaf entries at the last level */
if (lvl == ARM_LPAE_MAX_LEVELS - 1)
end = ptep;
else
end = (void *)ptep + table_size; end = (void *)ptep + table_size;
while (ptep != end) { while (ptep != end) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment