From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: [patch 3/3] KVM: only clear irq_source_id if irqchip is present Date: Thu, 29 Oct 2009 13:44:17 -0200 Message-ID: <20091029154554.054437735@amt.cnet> References: <20091029154414.686484229@amt.cnet> Cc: kvm@vger.kernel.org, mst@redhat.com, gleb@redhat.com, Marcelo Tosatti To: avi@redhat.com Return-path: Received: from mx1.redhat.com ([209.132.183.28]:65060 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755381AbZJ2PsF (ORCPT ); Thu, 29 Oct 2009 11:48:05 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9TFmBAm008710 for ; Thu, 29 Oct 2009 11:48:11 -0400 Content-Disposition: inline; filename=free-irqsource-id Sender: kvm-owner@vger.kernel.org List-ID: Otherwise kvm might attempt to dereference a NULL pointer. Signed-off-by: Marcelo Tosatti Index: kvm/virt/kvm/irq_comm.c =================================================================== --- kvm.orig/virt/kvm/irq_comm.c +++ kvm/virt/kvm/irq_comm.c @@ -243,6 +243,10 @@ void kvm_free_irq_source_id(struct kvm * 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 * 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); }