From: Takuya Yoshikawa Subject: [FIX PATCH] KVM: Use kvm_kvfree() to free memory allocated by kvm_kvzalloc() Date: Tue, 19 Jun 2012 22:04:56 +0900 Message-ID: <20120619220456.eedf64308ad08ac045cb9c56@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, yoshikawa.takuya@oss.ntt.co.jp To: avi@redhat.com, mtosatti@redhat.com Return-path: Received: from mail-pb0-f46.google.com ([209.85.160.46]:46209 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751484Ab2FSNFC (ORCPT ); Tue, 19 Jun 2012 09:05:02 -0400 Received: by pbbrp8 with SMTP id rp8so9631816pbb.19 for ; Tue, 19 Jun 2012 06:05:01 -0700 (PDT) Sender: kvm-owner@vger.kernel.org List-ID: From: Takuya Yoshikawa The following commit did not care about the error handling path: commit c1a7b32a14138f908df52d7c53b5ce3415ec6b50 KVM: Avoid wasting pages for small lpage_info arrays If memory allocation fails, vfree() will be called with the address returned by kzalloc(). This patch fixes this issue. Signed-off-by: Takuya Yoshikawa --- arch/x86/kvm/x86.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index a01a424..6ed5983 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6350,7 +6350,7 @@ int kvm_arch_create_memslot(struct kvm_memory_slot *slot, unsigned long npages) out_free: for (i = 0; i < KVM_NR_PAGE_SIZES - 1; ++i) { - vfree(slot->arch.lpage_info[i]); + kvm_kvfree(slot->arch.lpage_info[i]); slot->arch.lpage_info[i] = NULL; } return -ENOMEM; -- 1.7.5.4