KVM: MMU: fix missing percpu counter destroy
authorWei Yongjun <yjwei@cn.fujitsu.com>
Mon, 23 Aug 2010 08:13:15 +0000 (16:13 +0800)
committerAvi Kivity <avi@redhat.com>
Sun, 24 Oct 2010 08:51:21 +0000 (10:51 +0200)
commit ad05c88266b4cce1c820928ce8a0fb7690912ba1
(KVM: create aggregate kvm_total_used_mmu_pages value)
introduce percpu counter kvm_total_used_mmu_pages but never
destroy it, this may cause oops when rmmod & modprobe.

Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Acked-by: Tim Pepper <lnxninja@linux.vnet.ibm.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/kvm/mmu.c

index c2ac7004441ae323f77a8992121cdcfba4d41607..54a50268cebf511a4ff7a1e3aa90db32689f42b5 100644 (file)
@@ -3185,6 +3185,7 @@ static void mmu_destroy_caches(void)
 void kvm_mmu_module_exit(void)
 {
        mmu_destroy_caches();
+       percpu_counter_destroy(&kvm_total_used_mmu_pages);
        unregister_shrinker(&mmu_shrinker);
 }
 
@@ -3207,7 +3208,9 @@ int kvm_mmu_module_init(void)
        if (!mmu_page_header_cache)
                goto nomem;
 
-       percpu_counter_init(&kvm_total_used_mmu_pages, 0);
+       if (percpu_counter_init(&kvm_total_used_mmu_pages, 0))
+               goto nomem;
+
        register_shrinker(&mmu_shrinker);
 
        return 0;