[PATCH 03/13] RISC-V: KVM: Check kvm_riscv_vcpu_alloc_vector_context() return value

Anup Patel apatel at ventanamicro.com
Sun Jun 8 22:01:38 PDT 2025


On Fri, Jun 6, 2025 at 5:46 AM Atish Patra <atish.patra at linux.dev> wrote:
>
>
> On 6/4/25 11:14 PM, Anup Patel wrote:
> > The kvm_riscv_vcpu_alloc_vector_context() does return an error code
> > upon failure so don't ignore this in kvm_arch_vcpu_create().
>
> currently, kvm_riscv_vcpu_alloc_vector_context returns -ENOMEM only.
>
> Do you have some plans to return different errors in the future ?

Even if kvm_riscv_vcpu_alloc_vector_context() always returns -ENOMEM,
the caller should not assume anything about the return value.

>
> Otherwise, the code remains same before and after.
>
> > Signed-off-by: Anup Patel <apatel at ventanamicro.com>
> > ---
> >   arch/riscv/kvm/vcpu.c | 6 ++++--
> >   1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c
> > index e0a01af426ff..6a1914b21ec3 100644
> > --- a/arch/riscv/kvm/vcpu.c
> > +++ b/arch/riscv/kvm/vcpu.c
> > @@ -148,8 +148,10 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
> >
> >       spin_lock_init(&vcpu->arch.reset_state.lock);
> >
> > -     if (kvm_riscv_vcpu_alloc_vector_context(vcpu))
> > -             return -ENOMEM;
> > +     /* Setup VCPU vector context */
> The function name is pretty self explanatory. So no need of this comment ?

Yes, no need for this comment. I will drop it in the next revision.

> > +     rc = kvm_riscv_vcpu_alloc_vector_context(vcpu);
> > +     if (rc)
> > +             return rc;
> >
> >       /* Setup VCPU timer */
> >       kvm_riscv_vcpu_timer_init(vcpu);
>

Regards,
Anup



More information about the linux-riscv mailing list