From: Paolo Abeni <pabeni@redhat.com>
To: longli@microsoft.com
Cc: kotaranov@microsoft.com, erick.archer@outlook.com,
wei.liu@kernel.org, linux-hyperv@vger.kernel.org,
pabeni@redhat.com, shradhagupta@linux.microsoft.com,
haiyangz@microsoft.com, kys@microsoft.com, horms@kernel.org,
linux-kernel@vger.kernel.org, decui@microsoft.com,
schakrabarti@linux.microsoft.com, kuba@kernel.org,
davem@davemloft.net, edumazet@google.com, netdev@vger.kernel.org,
linux-rdma@vger.kernel.org
Subject: Re: [net-next,v3,4/6] net: mana: Use GIC functions to allocate global EQs
Date: Tue, 10 Mar 2026 15:29:31 +0100 [thread overview]
Message-ID: <20260310142931.237121-1-pabeni@redhat.com> (raw)
In-Reply-To: <20260306213302.544681-5-longli@microsoft.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: mana: Use GIC functions to allocate global EQs
Replace the GDMA global interrupt setup code with the new GIC allocation
and release functions for managing interrupt contexts.
> diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c
> index c43fd8089e77..bdc9dc437fb7 100644
> --- a/drivers/net/ethernet/microsoft/mana/gdma_main.c
> +++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c
[ ... ]
> @@ -2052,26 +1998,17 @@ static int mana_gd_setup_remaining_irqs(struct pci_dev *pdev)
> static void mana_gd_remove_irqs(struct pci_dev *pdev)
> {
> struct gdma_context *gc = pci_get_drvdata(pdev);
> - struct gdma_irq_context *gic;
> int irq, i;
>
> if (gc->max_num_msix < 1)
> return;
>
> - for (i = 0; i < gc->max_num_msix; i++) {
> - irq = pci_irq_vector(pdev, i);
> - if (irq < 0)
> - continue;
> -
> - gic = xa_load(&gc->irq_contexts, i);
> - if (WARN_ON(!gic))
> - continue;
> -
> + for (i = 0; i < (gc->msi_sharing ? gc->max_num_msix : 1); i++) {
^^^
Does this loop condition leak GIC references when msi_sharing is false?
When msi_sharing is false, the loop only releases the GIC at index 0.
However, mana_gd_setup_dyn_irqs allocates GICs at indices 1 through nvec:
drivers/net/ethernet/microsoft/mana/gdma_main.c:mana_gd_setup_dyn_irqs() {
for (i = 1; i <= nvec; i++) {
gic = mana_gd_get_gic(gc, false, &i);
...
}
}
Each mana_gd_get_gic call initializes the GIC with refcount=1. These GICs
at indices 1..nvec are never released because mana_gd_remove_irqs only
processes index 0 when msi_sharing is false.
The old code iterated over all gc->max_num_msix entries unconditionally:
for (i = 0; i < gc->max_num_msix; i++) {
...
gic = xa_load(&gc->irq_contexts, i);
...
free_irq(irq, gic);
xa_erase(&gc->irq_contexts, i);
kfree(gic);
}
This ensured every allocated GIC was freed. The new code with the
conditional loop breaks this, resulting in:
1. Leaked IRQ handlers - request_irq without matching free_irq for indices
1..nvec
2. Leaked gdma_irq_context memory - the GIC structures are never freed
3. Leaked xarray entries - the entries remain in gc->irq_contexts
Additionally, pci_free_irq_vectors is called immediately after the loop,
which attempts to tear down MSI-X vectors while IRQ handlers at indices
1..nvec are still registered. Can this trigger warnings or use-after-free
if an interrupt fires during teardown?
The next commit in the series (4475f13983ab "net: mana: Allocate interrupt
context for each EQ when creating vPort") adds per-EQ get/put of GICs,
but the EQ teardown only drops the EQ's reference (refcount goes from 2 to
1). The base reference from mana_gd_setup_dyn_irqs remains unreleased.
> /* Need to clear the hint before free_irq */
> + irq = pci_irq_vector(pdev, i);
> irq_update_affinity_hint(irq, NULL);
> - free_irq(irq, gic);
> - xa_erase(&gc->irq_contexts, i);
> - kfree(gic);
> +
> + mana_gd_put_gic(gc, false, i);
> }
>
> pci_free_irq_vectors(pdev);
next prev parent reply other threads:[~2026-03-10 14:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 21:32 [PATCH net-next v3 0/6] net: mana: Per-vPort EQ and MSI-X interrupt management Long Li
2026-03-06 21:32 ` [PATCH net-next v3 1/6] net: mana: Create separate EQs for each vPort Long Li
2026-03-06 21:32 ` [PATCH net-next v3 2/6] net: mana: Query device capabilities and configure MSI-X sharing for EQs Long Li
2026-03-06 21:32 ` [PATCH net-next v3 3/6] net: mana: Introduce GIC context with refcounting for interrupt management Long Li
2026-03-06 21:33 ` [PATCH net-next v3 4/6] net: mana: Use GIC functions to allocate global EQs Long Li
2026-03-10 14:29 ` Paolo Abeni [this message]
2026-03-10 19:03 ` [EXTERNAL] Re: [net-next,v3,4/6] " Long Li
2026-03-06 21:33 ` [PATCH net-next v3 5/6] net: mana: Allocate interrupt context for each EQ when creating vPort Long Li
2026-03-06 21:33 ` [PATCH net-next v3 6/6] RDMA/mana_ib: Allocate interrupt contexts on EQs Long Li
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=20260310142931.237121-1-pabeni@redhat.com \
--to=pabeni@redhat.com \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=edumazet@google.com \
--cc=erick.archer@outlook.com \
--cc=haiyangz@microsoft.com \
--cc=horms@kernel.org \
--cc=kotaranov@microsoft.com \
--cc=kuba@kernel.org \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=netdev@vger.kernel.org \
--cc=schakrabarti@linux.microsoft.com \
--cc=shradhagupta@linux.microsoft.com \
--cc=wei.liu@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox