]> git.hungrycats.org Git - linux/commitdiff
KVM: MMU: make __kvm_mmu_free_some_pages handle empty list
authorIzik Eidus <ieidus@redhat.com>
Fri, 18 Sep 2009 23:08:01 +0000 (20:08 -0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 5 Oct 2009 15:27:53 +0000 (08:27 -0700)
(cherry picked from commit 3b80fffe2b31fb716d3ebe729c54464ee7856723)

First check if the list is empty before attempting to look at list
entries.

Signed-off-by: Izik Eidus <ieidus@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/x86/kvm/mmu.c

index d7ce26babbbeb06a2ece2e04b0a25c2c6714a74f..a1c5e34e15fda2377190de8fcc9225c8892bd84a 100644 (file)
@@ -2612,7 +2612,8 @@ EXPORT_SYMBOL_GPL(kvm_mmu_unprotect_page_virt);
 
 void __kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu)
 {
-       while (vcpu->kvm->arch.n_free_mmu_pages < KVM_REFILL_PAGES) {
+       while (vcpu->kvm->arch.n_free_mmu_pages < KVM_REFILL_PAGES &&
+              !list_empty(&vcpu->kvm->arch.active_mmu_pages)) {
                struct kvm_mmu_page *sp;
 
                sp = container_of(vcpu->kvm->arch.active_mmu_pages.prev,