diff options
author | Christoffer Dall <cdall@linaro.org> | 2017-05-17 15:16:09 -0400 |
---|---|---|
committer | Christoffer Dall <cdall@linaro.org> | 2017-05-18 05:18:16 -0400 |
commit | fa472fa91a5a0b241f5ddae927d2e235d07545df (patch) | |
tree | 5d3abeb94ddab496eea44328c15f5d49a0e61259 | |
parent | 552c9f47f8d451830a6b47151c6d2db77f77cc3e (diff) |
KVM: arm/arm64: Hold slots_lock when unregistering 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
diligence.
Reported by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Christoffer Dall <cdall@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
-rw-r--r-- | virt/kvm/arm/vgic/vgic-mmio-v3.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c index 9b0f6810e7a8..201d5e2e973d 100644 --- a/virt/kvm/arm/vgic/vgic-mmio-v3.c +++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c | |||
@@ -614,15 +614,16 @@ int vgic_register_redist_iodev(struct kvm_vcpu *vcpu) | |||
614 | mutex_lock(&kvm->slots_lock); | 614 | mutex_lock(&kvm->slots_lock); |
615 | ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, sgi_base, | 615 | ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, sgi_base, |
616 | SZ_64K, &sgi_dev->dev); | 616 | SZ_64K, &sgi_dev->dev); |
617 | mutex_unlock(&kvm->slots_lock); | ||
618 | if (ret) { | 617 | if (ret) { |
619 | kvm_io_bus_unregister_dev(kvm, KVM_MMIO_BUS, | 618 | kvm_io_bus_unregister_dev(kvm, KVM_MMIO_BUS, |
620 | &rd_dev->dev); | 619 | &rd_dev->dev); |
621 | return ret; | 620 | goto out; |
622 | } | 621 | } |
623 | 622 | ||
624 | vgic->vgic_redist_free_offset += 2 * SZ_64K; | 623 | vgic->vgic_redist_free_offset += 2 * SZ_64K; |
625 | return 0; | 624 | out: |
625 | mutex_unlock(&kvm->slots_lock); | ||
626 | return ret; | ||
626 | } | 627 | } |
627 | 628 | ||
628 | static void vgic_unregister_redist_iodev(struct kvm_vcpu *vcpu) | 629 | static void vgic_unregister_redist_iodev(struct kvm_vcpu *vcpu) |
@@ -647,10 +648,12 @@ static int vgic_register_all_redist_iodevs(struct kvm *kvm) | |||
647 | 648 | ||
648 | if (ret) { | 649 | if (ret) { |
649 | /* The current c failed, so we start with the previous one. */ | 650 | /* The current c failed, so we start with the previous one. */ |
651 | mutex_lock(&kvm->slots_lock); | ||
650 | for (c--; c >= 0; c--) { | 652 | for (c--; c >= 0; c--) { |
651 | vcpu = kvm_get_vcpu(kvm, c); | 653 | vcpu = kvm_get_vcpu(kvm, c); |
652 | vgic_unregister_redist_iodev(vcpu); | 654 | vgic_unregister_redist_iodev(vcpu); |
653 | } | 655 | } |
656 | mutex_unlock(&kvm->slots_lock); | ||
654 | } | 657 | } |
655 | 658 | ||
656 | return ret; | 659 | return ret; |