Skip to content
Commit f6a27d6d authored by Oliver Upton's avatar Oliver Upton Committed by Marc Zyngier
Browse files

KVM: arm64: Drop last page ref in kvm_pgtable_stage2_free_removed()



The reference count on page table allocations is increased for every
'counted' PTE (valid or donated) in the table in addition to the initial
reference from ->zalloc_page(). kvm_pgtable_stage2_free_removed() fails
to drop the last reference on the root of the table walk, meaning we
leak memory.

Fix it by dropping the last reference after the free walker returns,
at which point all references for 'counted' PTEs have been released.

Cc: stable@vger.kernel.org
Fixes: 5c359cca ("KVM: arm64: Tear down unlinked stage-2 subtree after break-before-make")
Reported-by: default avatarYu Zhao <yuzhao@google.com>
Signed-off-by: default avatarOliver Upton <oliver.upton@linux.dev>
Tested-by: default avatarYu Zhao <yuzhao@google.com>
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20230530193213.1663411-1-oliver.upton@linux.dev
parent 811154e2
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment