Skip to contentSkip to conversation

Use kmem_cache_free for kmem_cache_zalloc'ed objects

PATCH New Rusty Russell 1 participant 1 message Aug 1, 2007 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use kmem_cache_free for kmem_cache_zalloc'ed objects

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().

drivers/kvm/svm.c +2 -2
diff -r 7e054bfac61d drivers/kvm/svm.c
@@ -592,7 +592,7 @@ uninit:
 uninit:
 	kvm_vcpu_uninit(&svm->vcpu);
 free_svm:
-	kfree(svm);
+	kmem_cache_free(kvm_vcpu_cache, svm);
 out:
 	return ERR_PTR(err);
 }
@@ -603,7 +603,7 @@ static void svm_free_vcpu(struct kvm_vcp
 
 	__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)
drivers/kvm/vmx.c +2 -2
diff -r 7e054bfac61d drivers/kvm/vmx.c
@@ -2344,7 +2344,7 @@ static void vmx_free_vcpu(struct kvm_vcp
 	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)
@@ -2395,7 +2395,7 @@ uninit_vcpu:
 uninit_vcpu:
 	kvm_vcpu_uninit(&vmx->vcpu);
 free_vcpu:
-	kfree(vmx);
+	kmem_cache_free(kvm_vcpu_cache, vmx);
 	return ERR_PTR(err);
 }
 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/