[PATCH v2 v2] PCI/MSI: Fix memory leak in pci_alloc_irq_vectors_affinity INTx path
From: neilfsun
Date: Mon Apr 20 2026 - 23:26:44 EST
In the INTx fallback path of pci_alloc_irq_vectors_affinity(),
affinity masks are created and never freed.
Signed-off-by: neilfsun <neilfsun@xxxxxxxxxxx>
Signed-off-by: Sun Feng <loyou85@xxxxxxxxx>
Reviewed-by: Hans Zhang <18255117159@xxxxxxx>
---
v2: use __free to auto-release pointers
---
drivers/pci/msi/api.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c
index c18559b6272c..994f12813ce3 100644
--- a/drivers/pci/msi/api.c
+++ b/drivers/pci/msi/api.c
@@ -285,8 +285,10 @@ int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
* the device driver can adjust queue configuration
* for the single interrupt case.
*/
- if (affd)
- irq_create_affinity_masks(1, affd);
+ if (affd) {
+ struct irq_affinity_desc *masks __free(kfree) =
+ irq_create_affinity_masks(1, affd);
+ }
pci_intx(dev, 1);
return 1;
}
--
2.52.0