Skip to content

Commit

Permalink
KVM: MMU: Fix potential memory leak with smp real-mode
Browse files Browse the repository at this point in the history
When we map a page, we check whether some other vcpu mapped it for us and if
so, bail out.  But we should decrease the refcount on the page as we do so.

Signed-off-by: Izik Eidus <izike@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
  • Loading branch information
Izik Eidus authored and Avi Kivity committed Jan 30, 2008
1 parent 2d2a7b9 commit 2065b37
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/kvm/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -907,8 +907,10 @@ static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, hpa_t p)

pte = table[index];
was_rmapped = is_rmap_pte(pte);
if (is_shadow_present_pte(pte) && is_writeble_pte(pte))
if (is_shadow_present_pte(pte) && is_writeble_pte(pte)) {
kvm_release_page(pfn_to_page(p >> PAGE_SHIFT));
return 0;
}
mark_page_dirty(vcpu->kvm, v >> PAGE_SHIFT);
page_header_update_slot(vcpu->kvm, table, v);
table[index] = p | PT_PRESENT_MASK | PT_WRITABLE_MASK |
Expand Down

0 comments on commit 2065b37

Please sign in to comment.