* [PATCH 1/1] KVM: fix lock imbalance
@ 2009-09-25 7:33 Jiri Slaby
2009-09-27 8:42 ` Avi Kivity
0 siblings, 1 reply; 2+ messages in thread
From: Jiri Slaby @ 2009-09-25 7:33 UTC (permalink / raw)
To: avi; +Cc: kvm, linux-kernel, Jiri Slaby, Marcelo Tosatti
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: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
---
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 15a83b9..00c68d2 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -220,11 +220,13 @@ int kvm_request_irq_source_id(struct kvm *kvm)
if (irq_source_id >= sizeof(kvm->arch.irq_sources_bitmap)) {
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;
@@ -240,7 +242,7 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id)
if (irq_source_id < 0 ||
irq_source_id >= sizeof(kvm->arch.irq_sources_bitmap)) {
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.vioapic->irq_states[i]);
@@ -251,6 +253,7 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id)
#endif
}
clear_bit(irq_source_id, &kvm->arch.irq_sources_bitmap);
+unlock:
mutex_unlock(&kvm->irq_lock);
}
--
1.6.4.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] KVM: fix lock imbalance
2009-09-25 7:33 [PATCH 1/1] KVM: fix lock imbalance Jiri Slaby
@ 2009-09-27 8:42 ` Avi Kivity
0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2009-09-27 8:42 UTC (permalink / raw)
To: Jiri Slaby; +Cc: kvm, linux-kernel, Marcelo Tosatti
On 09/25/2009 10:33 AM, Jiri Slaby wrote:
> 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.
>
Applied, thanks.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-09-27 8:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-25 7:33 [PATCH 1/1] KVM: fix lock imbalance Jiri Slaby
2009-09-27 8:42 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).