From patchwork Fri Mar 12 07:52:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 85216 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2C7n3uu003415 for ; Fri, 12 Mar 2010 07:49:03 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752513Ab0CLHs5 (ORCPT ); Fri, 12 Mar 2010 02:48:57 -0500 Received: from serv2.oss.ntt.co.jp ([222.151.198.100]:36087 "EHLO serv2.oss.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752387Ab0CLHs5 (ORCPT ); Fri, 12 Mar 2010 02:48:57 -0500 Received: from serv2.oss.ntt.co.jp (localhost [127.0.0.1]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id 75B4024834C; Fri, 12 Mar 2010 16:48:55 +0900 (JST) Received: from serv1.oss.ntt.co.jp (serv1.oss.ntt.co.jp [172.19.0.2]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id 664AC248295; Fri, 12 Mar 2010 16:48:55 +0900 (JST) Received: from yshtky3.kern.oss.ntt.co.jp (unknown [172.17.1.19]) by serv1.oss.ntt.co.jp (Postfix) with SMTP id 3B7EA11C0B2; Fri, 12 Mar 2010 16:48:55 +0900 (JST) Date: Fri, 12 Mar 2010 16:52:06 +0900 From: Takuya Yoshikawa To: avi@redhat.com, mtosatti@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH -v2] KVM: fix kvm_coalesced_mmio_init()'s error handling Message-Id: <20100312165206.ded1c10a.yoshikawa.takuya@oss.ntt.co.jp> In-Reply-To: <20100312120523.1b147c58.yoshikawa.takuya@oss.ntt.co.jp> References: <20100312120523.1b147c58.yoshikawa.takuya@oss.ntt.co.jp> X-Mailer: Sylpheed 2.6.0 (GTK+ 2.16.1; i486-pc-linux-gnu) Mime-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 12 Mar 2010 07:49:07 +0000 (UTC) === 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. 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;