]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
KVM: only clear irq_source_id if irqchip is present
authorMarcelo Tosatti <mtosatti@redhat.com>
Thu, 29 Oct 2009 15:44:17 +0000 (13:44 -0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 28 Jan 2010 23:02:50 +0000 (15:02 -0800)
commit e50212bb51356f0df48d6cce0aae5acf41df336d upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
virt/kvm/irq_comm.c

index ddc388e565fc459aec5f5e1168bf8f6c7b7535b5..5288885637b199f4f6feec0cef3c0767304fd468 100644 (file)
@@ -233,9 +233,12 @@ 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.irq_states[i]);
-       clear_bit(irq_source_id, &kvm->arch.irq_sources_bitmap);
 unlock:
        mutex_unlock(&kvm->irq_lock);
 }