Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1607686

Re: [PATCH v1] KVM: kvm_io_bus_unregister_dev() should never fail

From David Hildenbrand <david@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH v1] KVM: kvm_io_bus_unregister_dev() should never fail
Date 2017-03-23 17:30 +0100
Message-ID <todMC-4Je-23@gated-at.bofh.it> (permalink)
References <toc4a-3pL-23@gated-at.bofh.it> <todtg-4AG-9@gated-at.bofh.it>
Organization Red Hat GmbH

Show all headers | View raw


> 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;
>>  }
> 


-- 

Thanks,

David

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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