提交 175504cd 编写于 作者: T Takuya Yoshikawa 提交者: Avi Kivity

KVM: Take missing slots_lock for kvm_io_bus_unregister_dev()

In KVM_CREATE_IRQCHIP, kvm_io_bus_unregister_dev() is called without taking
slots_lock in the error handling path.
Signed-off-by: NTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Signed-off-by: NAvi Kivity <avi@redhat.com>
上级 a355c85c
...@@ -951,7 +951,9 @@ long kvm_arch_vm_ioctl(struct file *filp, ...@@ -951,7 +951,9 @@ long kvm_arch_vm_ioctl(struct file *filp,
goto out; goto out;
r = kvm_setup_default_irq_routing(kvm); r = kvm_setup_default_irq_routing(kvm);
if (r) { if (r) {
mutex_lock(&kvm->slots_lock);
kvm_ioapic_destroy(kvm); kvm_ioapic_destroy(kvm);
mutex_unlock(&kvm->slots_lock);
goto out; goto out;
} }
break; break;
......
...@@ -3309,8 +3309,10 @@ long kvm_arch_vm_ioctl(struct file *filp, ...@@ -3309,8 +3309,10 @@ long kvm_arch_vm_ioctl(struct file *filp,
if (vpic) { if (vpic) {
r = kvm_ioapic_init(kvm); r = kvm_ioapic_init(kvm);
if (r) { if (r) {
mutex_lock(&kvm->slots_lock);
kvm_io_bus_unregister_dev(kvm, KVM_PIO_BUS, kvm_io_bus_unregister_dev(kvm, KVM_PIO_BUS,
&vpic->dev); &vpic->dev);
mutex_unlock(&kvm->slots_lock);
kfree(vpic); kfree(vpic);
goto create_irqchip_unlock; goto create_irqchip_unlock;
} }
...@@ -3321,10 +3323,12 @@ long kvm_arch_vm_ioctl(struct file *filp, ...@@ -3321,10 +3323,12 @@ long kvm_arch_vm_ioctl(struct file *filp,
smp_wmb(); smp_wmb();
r = kvm_setup_default_irq_routing(kvm); r = kvm_setup_default_irq_routing(kvm);
if (r) { if (r) {
mutex_lock(&kvm->slots_lock);
mutex_lock(&kvm->irq_lock); mutex_lock(&kvm->irq_lock);
kvm_ioapic_destroy(kvm); kvm_ioapic_destroy(kvm);
kvm_destroy_pic(kvm); kvm_destroy_pic(kvm);
mutex_unlock(&kvm->irq_lock); mutex_unlock(&kvm->irq_lock);
mutex_unlock(&kvm->slots_lock);
} }
create_irqchip_unlock: create_irqchip_unlock:
mutex_unlock(&kvm->lock); mutex_unlock(&kvm->lock);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册