[PATCH 6/7] s390/pci: add error cleanup in zpci_directed_irq_init

From: Tobias Schumacher

Date: Wed Aug 19 2026 - 04:54:02 EST


If per-CPU airq_iv allocation fails in the loop, previously allocated
vectors and arrays leak. Add proper error path to release all resources
on failure.

Fixes: f770950a4709 ("s390/pci: Migrate s390 IRQ logic to IRQ domain API")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Tobias Schumacher <ts@xxxxxxxxxxxxx>
---
arch/s390/pci/pci_irq.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c
index 1515d8d7460e..1ddf6b3625a2 100644
--- a/arch/s390/pci/pci_irq.c
+++ b/arch/s390/pci/pci_irq.c
@@ -586,7 +586,7 @@ static int __init zpci_directed_irq_init(void)

zpci_ibv = kzalloc_objs(*zpci_ibv, num_possible_cpus());
if (!zpci_ibv)
- return -ENOMEM;
+ goto out_free_sbv;

for_each_possible_cpu(cpu) {
/*
@@ -599,13 +599,25 @@ static int __init zpci_directed_irq_init(void)
AIRQ_IV_CACHELINE |
(!cpu ? AIRQ_IV_ALLOC : 0), NULL);
if (!zpci_ibv[cpu])
- return -ENOMEM;
+ goto out_free_ibv;
}
on_each_cpu(cpu_enable_directed_irq, NULL, 1);

zpci_irq_chip.irq_set_affinity = zpci_set_irq_affinity;

return 0;
+
+out_free_ibv:
+ for_each_possible_cpu(cpu) {
+ if (zpci_ibv[cpu])
+ airq_iv_release(zpci_ibv[cpu]);
+ }
+ kfree(zpci_ibv);
+ zpci_ibv = NULL;
+out_free_sbv:
+ airq_iv_release(zpci_sbv);
+ zpci_sbv = NULL;
+ return -ENOMEM;
}

static int __init zpci_floating_irq_init(void)

--
2.53.0