[tip: irq/msi] PCI/MSI: Use __free() for affinity masks

tip-bot2 for Thomas Gleixner
2025-04-09T18:54:33Z

The following commit has been merged into the irq/msi branch of tip:

Commit-ID: 5c0ba4f9d25eb35a8ef882115c9f9c2084acc4e7
Gitweb: https://git.kernel.org/tip/5c0ba4f9d25eb35a8ef882115c9f9c2084acc4e7
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 19 Mar 2025 11:56:50 +01:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 09 Apr 2025 20:47:30 +02:00

PCI/MSI: Use __free() for affinity masks

Let cleanup handle the freeing of the affinity mask. That prepares for
switching the MSI descriptor locking to a guard().

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://lore.kernel.org/all/20250319105506.444764312@linutronix.de

---
drivers/pci/msi/msi.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
index c26e516..85c2aba 100644
--- a/drivers/pci/msi/msi.c
+++ b/drivers/pci/msi/msi.c
@@ -350,7 +350,6 @@ static int msi_verify_entries(struct pci_dev *dev)
static int msi_capability_init(struct pci_dev *dev, int nvec,
struct irq_affinity *affd)
{
- struct irq_affinity_desc *masks = NULL;
struct msi_desc *entry, desc;
int ret;

@@ -361,8 +360,8 @@ static int msi_capability_init(struct pci_dev *dev, int nvec,
/* Disable MSI during setup in the hardware to erase stale state */
pci_msi_set_enable(dev, 0);

- if (affd)
- masks = irq_create_affinity_masks(nvec, affd);
+ struct irq_affinity_desc *masks __free(kfree) =
+ affd ? irq_create_affinity_masks(nvec, affd) : NULL;

msi_lock_descs(&dev->dev);
ret = msi_setup_msi_desc(dev, nvec, masks);
@@ -402,7 +401,6 @@ err:
pci_free_msi_irqs(dev);
unlock:
msi_unlock_descs(&dev->dev);
- kfree(masks);
return ret;
}

@@ -661,12 +659,10 @@ static void msix_mask_all(void __iomem *base, int tsize)
static int msix_setup_interrupts(struct pci_dev *dev, struct msix_entry *entries,
int nvec, struct irq_affinity *affd)
{
- struct irq_affinity_desc *masks = NULL;
+ struct irq_affinity_desc *masks __free(kfree) =
+ affd ? irq_create_affinity_masks(nvec, affd) : NULL;
int ret;

- if (affd)
- masks = irq_create_affinity_masks(nvec, affd);
-
msi_lock_descs(&dev->dev);
ret = msix_setup_msi_descs(dev, entries, nvec, masks);
if (ret)
@@ -688,7 +684,6 @@ out_free:
pci_free_msi_irqs(dev);
out_unlock:
msi_unlock_descs(&dev->dev);
- kfree(masks);
return ret;
}