Re: [PATCH 1/2] Fix NULL pointer dereferences if KVM is used without in-kernel irqchip

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 07, 2015 at 01:38:48PM +0300, Pavel Fedin wrote:
> Makes qemu working again with kernel-irqchip=off option
> 
> Signed-off-by: Pavel Fedin <p.fedin@xxxxxxxxxxx>
> ---
>  virt/kvm/arm/vgic.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> 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)
> -- 
> 2.4.4
> 

This feels like defensive programming and it's a bit weird to return
something from kvm_vgic_get_max_vcpus when there is no vgic...

I would probably guard the callers with irqchip_in_kernel instead.

-Christoffer
_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm



[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux