summaryrefslogtreecommitdiff
path: root/virt/kvm/irq_comm.c
diff options
context:
space:
mode:
authorMarcelo Tosatti <mtosatti@redhat.com>2009-10-29 18:44:17 +0300
committerAvi Kivity <avi@redhat.com>2009-12-03 10:32:23 +0300
commite50212bb51356f0df48d6cce0aae5acf41df336d (patch)
tree095f3af5f642936ef5dae5415d8817e6337a179e /virt/kvm/irq_comm.c
parent2204ae3c96e9a1fed50f7ee19ce092e69d7dfe82 (diff)
downloadlinux-e50212bb51356f0df48d6cce0aae5acf41df336d.tar.xz
KVM: only clear irq_source_id if irqchip is present
Otherwise kvm might attempt to dereference a NULL pointer. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt/kvm/irq_comm.c')
-rw-r--r--virt/kvm/irq_comm.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index 0d454d352717..9b077342ab54 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -243,6 +243,10 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id)
printk(KERN_ERR "kvm: IRQ source ID out of range!\n");
goto unlock;
}
+ clear_bit(irq_source_id, &kvm->arch.irq_sources_bitmap);
+ if (!irqchip_in_kernel(kvm))
+ goto unlock;
+
for (i = 0; i < KVM_IOAPIC_NUM_PINS; i++) {
clear_bit(irq_source_id, &kvm->arch.vioapic->irq_states[i]);
if (i >= 16)
@@ -251,7 +255,6 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id)
clear_bit(irq_source_id, &pic_irqchip(kvm)->irq_states[i]);
#endif
}
- clear_bit(irq_source_id, &kvm->arch.irq_sources_bitmap);
unlock:
mutex_unlock(&kvm->irq_lock);
}