[1/2] Fix NULL pointer dereferences if KVM is used without in-kernel irqchip
diff mbox

Message ID 46c62639f325ef935c4ca24c5fc9d5eb2b4a0979.1436264839.git.p.fedin@samsung.com
State New
Headers show

Commit Message

Pavel Fedin July 7, 2015, 11:11 a.m. UTC
Makes qemu working again with kernel-irqchip=off option

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
---
 virt/kvm/arm/vgic.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Patch
diff mbox

diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 78fb820..3420657 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -100,6 +100,9 @@  static bool queue_sgi(struct kvm_vcpu *vcpu, int irq)
 
 int kvm_vgic_map_resources(struct kvm *kvm)
 {
+	if (!kvm->arch.vgic.vm_ops.map_resources)
+		return 0;
+
 	return kvm->arch.vgic.vm_ops.map_resources(kvm, vgic);
 }
 
@@ -1637,7 +1640,7 @@  static int vgic_vcpu_init_maps(struct kvm_vcpu *vcpu, int nr_irqs)
  */
 int kvm_vgic_get_max_vcpus(void)
 {
-	return vgic->max_gic_vcpus;
+	return vgic ? vgic->max_gic_vcpus : KVM_MAX_VCPUS;
 }
 
 void kvm_vgic_destroy(struct kvm *kvm)