KVM: destruct kvm_io_device while unregistering it from kvm_io_bus
authorWei Wang <wei.w.wang@intel.com>
Tue, 7 Feb 2023 12:37:12 +0000 (20:37 +0800)
committerSean Christopherson <seanjc@google.com>
Tue, 13 Jun 2023 21:18:09 +0000 (14:18 -0700)
commit5ea5ca3c2b4bf4090232e18cfc515dcb52f914a6
treeceaa5ba4da71e1213afe13f44de19d8db1337137
parent5f643e460ab1298a32b7d0db104bfcab9d6165c0
KVM: destruct kvm_io_device while unregistering it from kvm_io_bus

Current usage of kvm_io_device requires users to destruct it with an extra
call of kvm_iodevice_destructor after the device gets unregistered from
kvm_io_bus. This is not necessary and can cause errors if a user forgot
to make the extra call.

Simplify the usage by combining kvm_iodevice_destructor into
kvm_io_bus_unregister_dev. This reduces LOCs a bit for users and can
avoid the leakage of destructing the device explicitly.

Signed-off-by: Wei Wang <wei.w.wang@intel.com>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20230207123713.3905-2-wei.w.wang@intel.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
include/kvm/iodev.h
virt/kvm/coalesced_mmio.c
virt/kvm/eventfd.c
virt/kvm/kvm_main.c