KVM: Use kmem_cache_free for kmem_cache_zalloc'ed objects
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 1 Aug 2007 04:46:11 +0000 (14:46 +1000)
committerAvi Kivity <avi@qumranet.com>
Sat, 13 Oct 2007 08:18:23 +0000 (10:18 +0200)
We use kfree in svm.c and vmx.c, and this works, but it could break at
any time.  kfree() is supposed to match up with kmalloc().

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Avi Kivity <avi@qumranet.com>
drivers/kvm/svm.c
drivers/kvm/vmx.c

index 3ec30d7c9b936ee74389167d1a084b136a6c674c..436bdff9b0bfcf4911707f102876da50d98c5038 100644 (file)
@@ -610,7 +610,7 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id)
 uninit:
        kvm_vcpu_uninit(&svm->vcpu);
 free_svm:
-       kfree(svm);
+       kmem_cache_free(kvm_vcpu_cache, svm);
 out:
        return ERR_PTR(err);
 }
@@ -621,7 +621,7 @@ static void svm_free_vcpu(struct kvm_vcpu *vcpu)
 
        __free_page(pfn_to_page(svm->vmcb_pa >> PAGE_SHIFT));
        kvm_vcpu_uninit(vcpu);
-       kfree(svm);
+       kmem_cache_free(kvm_vcpu_cache, svm);
 }
 
 static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
index ae54d9a24ce825ed02858a3711d7b64f8b38f259..708055a50521441dada14e2be002320fc613ad2f 100644 (file)
@@ -2359,7 +2359,7 @@ static void vmx_free_vcpu(struct kvm_vcpu *vcpu)
        kfree(vmx->host_msrs);
        kfree(vmx->guest_msrs);
        kvm_vcpu_uninit(vcpu);
-       kfree(vmx);
+       kmem_cache_free(kvm_vcpu_cache, vmx);
 }
 
 static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
@@ -2410,7 +2410,7 @@ free_guest_msrs:
 uninit_vcpu:
        kvm_vcpu_uninit(&vmx->vcpu);
 free_vcpu:
-       kfree(vmx);
+       kmem_cache_free(kvm_vcpu_cache, vmx);
        return ERR_PTR(err);
 }