From: Hans Zhang <18255117159@163.com>
To: neilfsun <loyou85@gmail.com>,
bhelgaas@google.com, shawn.lin@rock-chips.com,
hans.zhang@cixtech.com, tglx@kernel.org,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: neilfsun <neilfsun@tencent.com>
Subject: Re: [PATCH] PCI/MSI: Fix memory leak in pci_alloc_irq_vectors_affinity INTx path
Date: Mon, 20 Apr 2026 12:47:32 +0800 [thread overview]
Message-ID: <2caa071e-85ee-4e76-bb33-8f27a4579fac@163.com> (raw)
In-Reply-To: <20260420040940.14824-1-neilfsun@tencent.com>
On 4/20/26 12:09, neilfsun wrote:
> In the INTx fallback path of pci_alloc_irq_vectors_affinity(),
> affinity masks are created and never freed.
>
> Signed-off-by: neilfsun <neilfsun@tencent.com>
> Signed-off-by: Sun Feng <loyou85@gmail.com>
> ---
> drivers/pci/msi/api.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c
> index c18559b6272c..c1377f74b8f3 100644
> --- a/drivers/pci/msi/api.c
> +++ b/drivers/pci/msi/api.c
> @@ -280,14 +280,17 @@ int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
> /* use INTx IRQ if allowed */
> if (flags & PCI_IRQ_INTX) {
> if (min_vecs == 1 && dev->irq) {
> + struct irq_affinity_desc *masks = NULL;
> +
> /*
> * Invoke the affinity spreading logic to ensure that
> * the device driver can adjust queue configuration
> * for the single interrupt case.
> */
> if (affd)
> - irq_create_affinity_masks(1, affd);
> + masks = irq_create_affinity_masks(1, affd);
Hi,
Suggestion:
diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c
index c18559b6272c..0ce34db2b2bf 100644
--- a/drivers/pci/msi/api.c
+++ b/drivers/pci/msi/api.c
@@ -286,7 +286,8 @@ int pci_alloc_irq_vectors_affinity(struct pci_dev
*dev, unsigned int min_vecs,
* for the single interrupt case.
*/
if (affd)
- irq_create_affinity_masks(1, affd);
+ struct irq_affinity_desc *masks
__free(kfree) =
+ irq_create_affinity_masks(1, affd);
pci_intx(dev, 1);
return 1;
}
Best regards,
Hans
> pci_intx(dev, 1);
> + kfree(masks);
> return 1;
> }
> }
next prev parent reply other threads:[~2026-04-20 4:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 4:09 [PATCH] PCI/MSI: Fix memory leak in pci_alloc_irq_vectors_affinity INTx path neilfsun
2026-04-20 4:47 ` Hans Zhang [this message]
2026-04-21 3:20 ` [PATCH v2 v2] " neilfsun
2026-04-21 6:24 ` Shawn Lin
2026-04-21 8:06 ` Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2caa071e-85ee-4e76-bb33-8f27a4579fac@163.com \
--to=18255117159@163.com \
--cc=bhelgaas@google.com \
--cc=hans.zhang@cixtech.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=loyou85@gmail.com \
--cc=neilfsun@tencent.com \
--cc=shawn.lin@rock-chips.com \
--cc=tglx@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.