diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2009-09-25 09:33:38 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-01-28 15:02:49 -0800 |
commit | eaccd490b0128d11ce2ea4d9d89e092661ae90b5 (patch) | |
tree | 3215b673d9a7c47d14f718499b8fef9e0a9694ba /virt | |
parent | 9801911326462a332d83eb508f1120bd45178426 (diff) |
KVM: fix lock imbalance in kvm_*_irq_source_id()
commit 0c6ddcebd8303ada6faefa6f72ac18b6230320c4 upstream.
Stanse found 2 lock imbalances in kvm_request_irq_source_id and
kvm_free_irq_source_id. They omit to unlock kvm->irq_lock on fail paths.
Fix that by adding unlock labels at the end of the functions and jump
there from the fail paths.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/irq_comm.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index 03e5b217e88..ddc388e565f 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c @@ -209,11 +209,13 @@ int kvm_request_irq_source_id(struct kvm *kvm) if (irq_source_id >= BITS_PER_LONG) { printk(KERN_WARNING "kvm: exhaust allocatable IRQ sources!\n"); - return -EFAULT; + irq_source_id = -EFAULT; + goto unlock; } ASSERT(irq_source_id != KVM_USERSPACE_IRQ_SOURCE_ID); set_bit(irq_source_id, bitmap); +unlock: mutex_unlock(&kvm->irq_lock); return irq_source_id; @@ -229,11 +231,12 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id) if (irq_source_id < 0 || irq_source_id >= BITS_PER_LONG) { printk(KERN_ERR "kvm: IRQ source ID out of range!\n"); - return; + goto unlock; } for (i = 0; i < KVM_IOAPIC_NUM_PINS; i++) clear_bit(irq_source_id, &kvm->arch.irq_states[i]); clear_bit(irq_source_id, &kvm->arch.irq_sources_bitmap); +unlock: mutex_unlock(&kvm->irq_lock); } |