public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Wei Yongjun <yjwei@cn.fujitsu.com>
To: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Cc: avi@redhat.com, mtosatti@redhat.com, kvm@vger.kernel.org
Subject: Re: [PATCH -v2] KVM: fix kvm_coalesced_mmio_init()'s error handling
Date: Fri, 12 Mar 2010 15:56:45 +0800	[thread overview]
Message-ID: <4B99F3BD.40903@cn.fujitsu.com> (raw)
In-Reply-To: <20100312165206.ded1c10a.yoshikawa.takuya@oss.ntt.co.jp>

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 <yoshikawa.takuya@oss.ntt.co.jp>
> ---
>  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;
>   

  reply	other threads:[~2010-03-12  7:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-12  3:05 [PATCH] KVM: coalesced_mmio: NULLify the pointers before freeing ring page and dev Takuya Yoshikawa
2010-03-12  3:41 ` Wei Yongjun
2010-03-12  4:15   ` Takuya Yoshikawa
2010-03-12  3:43 ` [PATCH] KVM: fix to not use NULL kvm->coalesced_mmio_ring in kvm_vcpu_fault() Wei Yongjun
2010-03-12  4:22   ` Takuya Yoshikawa
2010-03-12  7:52 ` [PATCH -v2] KVM: fix kvm_coalesced_mmio_init()'s error handling Takuya Yoshikawa
2010-03-12  7:56   ` Wei Yongjun [this message]
2010-03-12  8:00     ` Takuya Yoshikawa
2010-03-12  9:57 ` [PATCH -v3 1/2] KVM: introduce kvm_uninit_mmu_notifier() Takuya Yoshikawa
2010-03-12 10:12   ` Takuya Yoshikawa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B99F3BD.40903@cn.fujitsu.com \
    --to=yjwei@cn.fujitsu.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=yoshikawa.takuya@oss.ntt.co.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox