Re: [PATCH] KVM: arm64: nv: Fix NULL dereference in kvm_inject_nested()
From: Dan Carpenter
Date: Wed Nov 18 2026 - 05:41:46 EST
On Mon, Nov 16, 2026 at 06:11:15PM +0000, Marc Zyngier wrote:
> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
> index 5959bbbfa026f..21cd872ea394b 100644
> --- a/arch/arm64/kvm/arm.c
> +++ b/arch/arm64/kvm/arm.c
> @@ -2007,7 +2007,7 @@ static int kvm_arm_vcpu_get_events(struct kvm_vcpu *vcpu,
> static int kvm_arm_vcpu_set_events(struct kvm_vcpu *vcpu,
> struct kvm_vcpu_events *events)
> {
> - int i;
> + int i, ret;
>
> /* check whether the reserved field is zero */
> for (i = 0; i < ARRAY_SIZE(events->reserved); i++)
> @@ -2019,7 +2019,11 @@ static int kvm_arm_vcpu_set_events(struct kvm_vcpu *vcpu,
> if (events->exception.pad[i])
> return -EINVAL;
>
> - return __kvm_arm_vcpu_set_events(vcpu, events);
> + vcpu_load(vcpu);
> + ret = __kvm_arm_vcpu_set_events(vcpu, events);
> + vcpu_put(vcpu);
> +
> + return ret;
> }
>
> /*
>
> and be done with it, avoiding the fast-path bloating altogether.
> Unless you can spot another path where the vcpu is not loaded, but
> still requires the injection of an exception?
I feel like this approach brings arm64 slightly more in line with
x86 so I like it. I'll send that.
I'm still redoing the TCR2 changes so I won't send those today.
regards,
dan carpenter