KVM: arm/arm64: Hold slots_lock when unregisering kvm io bus devices
PATCH 1/1 KVM: arm/arm64: Hold slots_lock when unregisering kvm io bus devices
We were not holding the kvm->slots_lock as required when calling kvm_io_bus_unregister_dev() as required.
This only affects the error path, but still, let's do our due dilligence.
Reported by: Eric Auger <[email protected]>
Signed-off-by Christoffer Dall <[email protected]>
--- virt/kvm/arm/vgic/vgic-mmio-v3.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
virt/kvm/arm/vgic/vgic-mmio-v3.c +6 -3
@@ -614,15 +614,16 @@ int vgic_register_redist_iodev(struct kvm_vcpu *vcpu)mutex_lock (&kvm->slots_lock); ret =kvm_io_bus_register_dev (kvm,KVM_MMIO_BUS , sgi_base,SZ_64K , &sgi_dev->dev); -mutex_unlock (&kvm->slots_lock);if (ret) {kvm_io_bus_unregister_dev (kvm,KVM_MMIO_BUS , &rd_dev->dev); -return ret; + goto out; } vgic->vgic_redist_free_offset +=2 *SZ_64K ; -return 0 ; +out: +mutex_unlock (&kvm->slots_lock); +return ret; }static void vgic_unregister_redist_iodev (struct kvm_vcpu *vcpu)
@@ -647,10 +648,12 @@ static int vgic_register_all_redist_iodevs(struct kvm *kvm)if (ret) {/* The current c failed, so we start with the previous one. */ +mutex_lock (&kvm->slots_lock);for (c--; c >=0 ; c--) { vcpu =kvm_get_vcpu (kvm, c);vgic_unregister_redist_iodev (vcpu); } +mutex_unlock (&kvm->slots_lock); }return ret;
Signature · 1 line
2.9.0
Hi Christoffer,
Quoted 8 lines · Christoffer Dall
We were not holding the
kvm->slots_lockas required when callingkvm_io_bus_unregister_dev()as required.This only affects the error path, but still, let's do our due dilligence.
Reported by: Eric Auger <[email protected]>
Signed-off-by Christoffer Dall <[email protected]>
Besides the typo in the commit title
Reviewed-by Eric Auger <[email protected]>
Thanks
Eric
Quoted 42 lines
--- virt/kvm/arm/vgic/vgic-mmio-v3.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)virt/kvm/arm/vgic/vgic-mmio-v3.c +6
-3@@ -614,15 +614,16 @@ int vgic_register_redist_iodev(struct kvm_vcpu *vcpu)mutex_lock (&kvm->slots_lock); ret =kvm_io_bus_register_dev (kvm,KVM_MMIO_BUS , sgi_base,SZ_64K , &sgi_dev->dev); -mutex_unlock (&kvm->slots_lock);if (ret) {kvm_io_bus_unregister_dev (kvm,KVM_MMIO_BUS , &rd_dev->dev); -return ret; + goto out; } vgic->vgic_redist_free_offset +=2 *SZ_64K ; -return 0 ; +out: +mutex_unlock (&kvm->slots_lock); +return ret; }static void vgic_unregister_redist_iodev (struct kvm_vcpu *vcpu)@@ -647,10 +648,12 @@ static int vgic_register_all_redist_iodevs(struct kvm *kvm)if (ret) {/* The current c failed, so we start with the previous one. */ +mutex_lock (&kvm->slots_lock);for (c--; c >=0 ; c--) { vcpu =kvm_get_vcpu (kvm, c);vgic_unregister_redist_iodev (vcpu); } +mutex_unlock (&kvm->slots_lock); }return ret;