From: Marcelo Tosatti <mtosatti@redhat.com>
To: Wei Yongjun <yjwei@cn.fujitsu.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: only set kvm->arch.vioapic when success to init ioapic
Date: Mon, 8 Feb 2010 16:07:54 -0200 [thread overview]
Message-ID: <20100208180754.GC5415@amt.cnet> (raw)
In-Reply-To: <4B6FDB2D.9080707@cn.fujitsu.com>
On Mon, Feb 08, 2010 at 05:36:45PM +0800, Wei Yongjun wrote:
> kvm->arch.vioapic is always set either kvm_ioapic_init() is
> success or fail. If kvm_ioapic_init() is fail, the kvm->arch.vioapic
> may point a freed memory.
>
> Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
> ---
> virt/kvm/ioapic.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
> index a2edfd1..e13f529 100644
> --- a/virt/kvm/ioapic.c
> +++ b/virt/kvm/ioapic.c
> @@ -386,7 +386,6 @@ int kvm_ioapic_init(struct kvm *kvm)
> if (!ioapic)
> return -ENOMEM;
> mutex_init(&ioapic->lock);
> - kvm->arch.vioapic = ioapic;
> kvm_ioapic_reset(ioapic);
> kvm_iodevice_init(&ioapic->dev, &ioapic_mmio_ops);
> ioapic->kvm = kvm;
> @@ -395,6 +394,8 @@ int kvm_ioapic_init(struct kvm *kvm)
> mutex_unlock(&kvm->slots_lock);
> if (ret < 0)
> kfree(ioapic);
> + else
> + kvm->arch.vioapic = ioapic;
>
> return ret;
> }
Same thing as with the PIT issue, kvm->arch.vioapic must be set
before kvm_io_bus_register_dev.
But you're right that kvm->arch.vioapic should be NULLified in case of
failure.
next prev parent reply other threads:[~2010-02-08 18:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-08 9:01 [PATCH 1/2] KVM: PIT: remove useless code from kvm_create_pit() Wei Yongjun
2010-02-08 9:03 ` [PATCH 2/2] KVM: PIT: unregister kvm irq notifier if fail to create pit Wei Yongjun
2010-02-08 9:36 ` [PATCH] KVM: only set kvm->arch.vioapic when success to init ioapic Wei Yongjun
2010-02-08 9:56 ` [PATCH] KVM: ia64: clear kvm->arch.vioapic if fail to create irq chip Wei Yongjun
2010-02-09 2:28 ` Wei Yongjun
2010-02-08 18:07 ` Marcelo Tosatti [this message]
2010-02-09 1:18 ` [PATCHv2] KVM: kvm->arch.vioapic should be NULL if kvm_ioapic_init() failure Wei Yongjun
2010-02-09 2:28 ` Wei Yongjun
2010-02-08 18:05 ` [PATCH 2/2] KVM: PIT: unregister kvm irq notifier if fail to create pit Marcelo Tosatti
2010-02-09 10:40 ` Avi Kivity
2010-02-08 18:00 ` [PATCH 1/2] KVM: PIT: remove useless code from kvm_create_pit() Marcelo Tosatti
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=20100208180754.GC5415@amt.cnet \
--to=mtosatti@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=yjwei@cn.fujitsu.com \
/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