From: Izik Eidus Date: Tue, 20 Nov 2007 09:30:04 +0000 (+0200) Subject: KVM: MMU: Fix potential memory leak with smp real-mode X-Git-Tag: v2.6.25-rc1~1138^2~112 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=2065b3727ecdb64450597d70f7e13af00b85dbd8;p=linux-2.6-omap-h63xx.git KVM: MMU: Fix potential memory leak with smp real-mode 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 Signed-off-by: Avi Kivity --- diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c index 87d8e70fe50..8add4d5c684 100644 --- a/drivers/kvm/mmu.c +++ b/drivers/kvm/mmu.c @@ -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 |