From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Yongjun Subject: Re: [PATCH -v2] KVM: fix kvm_coalesced_mmio_init()'s error handling Date: Fri, 12 Mar 2010 15:56:45 +0800 Message-ID: <4B99F3BD.40903@cn.fujitsu.com> References: <20100312120523.1b147c58.yoshikawa.takuya@oss.ntt.co.jp> <20100312165206.ded1c10a.yoshikawa.takuya@oss.ntt.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: avi@redhat.com, mtosatti@redhat.com, kvm@vger.kernel.org To: Takuya Yoshikawa Return-path: Received: from cn.fujitsu.com ([222.73.24.84]:52587 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752766Ab0CLHzA (ORCPT ); Fri, 12 Mar 2010 02:55:00 -0500 In-Reply-To: <20100312165206.ded1c10a.yoshikawa.takuya@oss.ntt.co.jp> Sender: kvm-owner@vger.kernel.org List-ID: Takuya Yoshikawa wrote: > This version may be better. > > Thanks, > Takuya > > === > kvm_coalesced_mmio_init() keeps to hold the addresses of a coalesced mmio > ring page and dev even after it has freed them. > > Also, if this function fails, though it must be rare, it seems to be > suggesting the system's serious state. > > This patch changes the error handling for this function to fix these issues. > We must also unregister mmu_notifier in the error path. > Signed-off-by: Takuya Yoshikawa > --- > virt/kvm/coalesced_mmio.c | 2 ++ > virt/kvm/kvm_main.c | 4 +++- > 2 files changed, 5 insertions(+), 1 deletions(-) > > diff --git a/virt/kvm/coalesced_mmio.c b/virt/kvm/coalesced_mmio.c > index 5169736..11776b7 100644 > --- a/virt/kvm/coalesced_mmio.c > +++ b/virt/kvm/coalesced_mmio.c > @@ -119,8 +119,10 @@ int kvm_coalesced_mmio_init(struct kvm *kvm) > return ret; > > out_free_dev: > + kvm->coalesced_mmio_dev = NULL; > kfree(dev); > out_free_page: > + kvm->coalesced_mmio_ring = NULL; > __free_page(page); > out_err: > return ret; > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index e758ef7..9e72067 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -419,7 +419,9 @@ static struct kvm *kvm_create_vm(void) > list_add(&kvm->vm_list, &vm_list); > spin_unlock(&kvm_lock); > #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET > - kvm_coalesced_mmio_init(kvm); > + r = kvm_coalesced_mmio_init(kvm); > + if (r < 0) > + goto out_err; > #endif > out: > return kvm; >