From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: David Hildenbrand <david@redhat.com>
Cc: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
rkrcmar@redhat.com, Dmitry Vyukov <dvyukov@google.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
stable@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1] KVM: kvm_io_bus_unregister_dev() should never fail
Date: Thu, 23 Mar 2017 17:40:13 +0100 [thread overview]
Message-ID: <20170323174013.7509b714.cornelia.huck@de.ibm.com> (raw)
In-Reply-To: <48d409b3-d584-eaa3-24ca-e7330d6fc0e1@redhat.com>
On Thu, 23 Mar 2017 17:20:48 +0100
David Hildenbrand <david@redhat.com> wrote:
>
> > As this may set kvm->buses[bus_idx] to NULL, don't you also need to
> > guard for bus == NULL in kvm_io_bus_destroy()? (I looked at the code on
> > kvm/queue.)
>
> very right, so something like this?
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index e1be4b4..ef1aa7f 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -728,7 +728,8 @@ static void kvm_destroy_vm(struct kvm *kvm)
> spin_unlock(&kvm_lock);
> kvm_free_irq_routing(kvm);
> for (i = 0; i < KVM_NR_BUSES; i++) {
> - kvm_io_bus_destroy(kvm->buses[i]);
> + if (kvm->buses[i])
> + kvm_io_bus_destroy(kvm->buses[i]);
> kvm->buses[i] = NULL;
> }
> kvm_coalesced_mmio_free(kvm);
>
> Thanks!
>
> >
> >> synchronize_srcu_expedited(&kvm->srcu);
> >> kfree(bus);
> >> - return r;
> >> + return;
> >> }
> >
>
>
Either that, or an early exit for bus == NULL in kvm_io_bus_destroy().
(I think the second option is more straightforward.)
next prev parent reply other threads:[~2017-03-23 16:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-23 14:34 [PATCH v1] KVM: kvm_io_bus_unregister_dev() should never fail David Hildenbrand
2017-03-23 16:06 ` Cornelia Huck
2017-03-23 16:20 ` David Hildenbrand
2017-03-23 16:40 ` Cornelia Huck [this message]
2017-03-23 17:15 ` David Hildenbrand
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=20170323174013.7509b714.cornelia.huck@de.ibm.com \
--to=cornelia.huck@de.ibm.com \
--cc=david@redhat.com \
--cc=dvyukov@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=stable@vger.kernel.org \
/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