Re: [PATCH] KVM: PPC: Book3S HV: Set irqfd->producer only on success

From: Vaibhav Jain

Date: Thu Jul 09 2026 - 03:54:07 EST


Hi leixiang,

Thanks for catching and fixing this for kvm-hv:

leixiang <leixiang@xxxxxxxxxx> writes:

> Set irqfd->producer only after kvmppc_set_passthru_irq() succeeds to
> avoid leaving a dangling pointer on failure. The bypass manager does
> not register a failed producer, so the pointer is never cleared.
>
> Fixes: c57875f5f9be ("KVM: PPC: Book3S HV: Enable IRQ bypass")
> Suggested-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: leixiang <leixiang@xxxxxxxxxx>
> ---
> arch/powerpc/kvm/book3s_hv.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 61dbeea317f3..ff7b25629125 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -6111,12 +6111,12 @@ static int kvmppc_irq_bypass_add_producer_hv(struct irq_bypass_consumer *cons,
> struct kvm_kernel_irqfd *irqfd =
> container_of(cons, struct kvm_kernel_irqfd, consumer);
>
> - irqfd->producer = prod;
> -
> ret = kvmppc_set_passthru_irq(irqfd->kvm, prod->irq, irqfd->gsi);
> if (ret)
> pr_info("kvmppc_set_passthru_irq (irq %d, gsi %d) fails: %d\n",
> prod->irq, irqfd->gsi, ret);
> + else
> + irqfd->producer = prod;
>
> return ret;
> }
> --
> 2.45.0
>

Proposed new error handling path looks better compared to v1 of the
patch. Also agree to the changes made.


Hence,

Reviewed-by: Vaibhav Jain <vaibhav@xxxxxxxxxxxxx>

--
Cheers
~ Vaibhav