]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: arm64: vgic-v3: Release reserved slot outside of lpi_xa's lock
authorOliver Upton <oupton@kernel.org>
Fri, 7 Nov 2025 18:48:47 +0000 (10:48 -0800)
committerMarc Zyngier <maz@kernel.org>
Sat, 8 Nov 2025 11:19:32 +0000 (11:19 +0000)
xa_release() expects to be called outside of the xa_lock. Fix
vgic_add_lpi() to drop the lock before calling and restructure to get
rid of the goto label.

Reported-by: Zenghui Yu <yuzenghui@huawei.com>
Closes: https://lore.kernel.org/kvmarm/d0853e82-7d95-5025-7abf-c6f1e0cdf7b5@huawei.com/
Fixes: 481c9ee846d2 ("KVM: arm64: vgic-its: Get rid of the lpi_list_lock")
Signed-off-by: Oliver Upton <oupton@kernel.org>
Link: https://patch.msgid.link/20251107184847.1784820-3-oupton@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/vgic/vgic-its.c

index f162206adb482ac0d2eb5c709ed36c4d508d1855..3f1c4b10fed9007e627c4d8aa7c9b567f5c44cbe 100644 (file)
@@ -115,21 +115,18 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid,
                /* Someone was faster with adding this LPI, lets use that. */
                kfree(irq);
                irq = oldirq;
-
-               goto out_unlock;
+       } else {
+               ret = xa_err(__xa_store(&dist->lpi_xa, intid, irq, 0));
        }
 
-       ret = xa_err(__xa_store(&dist->lpi_xa, intid, irq, 0));
+       xa_unlock_irqrestore(&dist->lpi_xa, flags);
+
        if (ret) {
                xa_release(&dist->lpi_xa, intid);
                kfree(irq);
-       }
 
-out_unlock:
-       xa_unlock_irqrestore(&dist->lpi_xa, flags);
-
-       if (ret)
                return ERR_PTR(ret);
+       }
 
        /*
         * We "cache" the configuration table entries in our struct vgic_irq's.