From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Yongjun Subject: Re: [PATCH] KVM: coalesced_mmio: NULLify the pointers before freeing ring page and dev Date: Fri, 12 Mar 2010 11:41:40 +0800 Message-ID: <4B99B7F4.5090406@cn.fujitsu.com> References: <20100312120523.1b147c58.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]:54620 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751228Ab0CLDj4 (ORCPT ); Thu, 11 Mar 2010 22:39:56 -0500 In-Reply-To: <20100312120523.1b147c58.yoshikawa.takuya@oss.ntt.co.jp> Sender: kvm-owner@vger.kernel.org List-ID: Takuya Yoshikawa wrote: > kvm_coalesced_mmio_init() keeps to hold the addresses of a coalesced mmio > ring page and dev even after it has freed them. > > This may trigger problems, e.g., if we call kvm_coalesced_mmio_free() in > kvm_destroy_vm() or kvm_vm_ioctl_register_coalesced_mmio() afterward. > > This patch avoids such problems by NULLifying the pointers. > After this patch, I think we also need to do some check in kvm_vcpu_fault() for coalesced_mmio_ring, since the coalesced_mmio may not be init correctly. This is other issue, so I will send a new patch for this. > Signed-off-by: Takuya Yoshikawa > --- > virt/kvm/coalesced_mmio.c | 2 ++ > 1 files changed, 2 insertions(+), 0 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; >