Re: [patch V4 07/14] PCI/MSI: Use __free() for affinity masks

Bjorn Helgaas
2025-03-19T17:09:10Z

On Wed, Mar 19, 2025 at 11:56:50AM +0100, Thomas Gleixner wrote:
> 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>

> ---
> V4: Split out of the previous combo patch
> ---
> drivers/pci/msi/msi.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> --- a/drivers/pci/msi/msi.c
> +++ b/drivers/pci/msi/msi.c
> @@ -351,7 +351,6 @@ static int msi_verify_entries(struct pci
> 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;
>
> @@ -362,8 +361,8 @@ static int msi_capability_init(struct pc
> /* 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);
> @@ -403,7 +402,6 @@ static int msi_capability_init(struct pc
> pci_free_msi_irqs(dev);
> unlock:
> msi_unlock_descs(&dev->dev);
> - kfree(masks);
> return ret;
> }
>
> @@ -664,12 +662,10 @@ static void msix_mask_all(void __iomem *
> 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)
> @@ -691,7 +687,6 @@ static int msix_setup_interrupts(struct
> pci_free_msi_irqs(dev);
> out_unlock:
> msi_unlock_descs(&dev->dev);
> - kfree(masks);
> return ret;
> }
>
>