Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1607696
| From | Cornelia Huck <cornelia.huck@de.ibm.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v1] KVM: kvm_io_bus_unregister_dev() should never fail |
| Date | 2017-03-23 17:50 +0100 |
| Message-ID | <toe5X-4Wc-3@gated-at.bofh.it> (permalink) |
| References | <toc4a-3pL-23@gated-at.bofh.it> <todtg-4AG-9@gated-at.bofh.it> <todMC-4Je-23@gated-at.bofh.it> |
| Organization | IBM Deutschland Research & Development GmbH Vorsitzende des Aufsichtsrats: Martina Koederitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294 |
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.)
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v1] KVM: kvm_io_bus_unregister_dev() should never fail David Hildenbrand <david@redhat.com> - 2017-03-23 15:40 +0100
Re: [PATCH v1] KVM: kvm_io_bus_unregister_dev() should never fail Cornelia Huck <cornelia.huck@de.ibm.com> - 2017-03-23 17:10 +0100
Re: [PATCH v1] KVM: kvm_io_bus_unregister_dev() should never fail David Hildenbrand <david@redhat.com> - 2017-03-23 17:30 +0100
Re: [PATCH v1] KVM: kvm_io_bus_unregister_dev() should never fail Cornelia Huck <cornelia.huck@de.ibm.com> - 2017-03-23 17:50 +0100
Re: [PATCH v1] KVM: kvm_io_bus_unregister_dev() should never fail David Hildenbrand <david@redhat.com> - 2017-03-23 18:20 +0100
csiph-web