Linux-HyperV List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wei Hu" <weh@linux.microsoft.com>
Cc: linux-hyperv@vger.kernel.org, linux-rdma@vger.kernel.org,
	bpf@vger.kernel.org
Subject: Re: [PATCH net-next v6 02/13] net: mana: share the EQ pool across a queue-set swap
Date: Sat, 10 Oct 2026 14:42:03 +0000	[thread overview]
Message-ID: <sashiko-outbox-166658@kernel.org> (raw)
In-Reply-To: <5e46da0c96a1dd7c39ae856deccc82cd98ac1af5.1790795005.git.weh@linux.microsoft.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] net: mana: leak of DMA region handle in mana_gd_create_mana_eq() error path
--

commit 1d0366c5b44b66d602e9a488b5674896e64e1285
Author: Long Li <longli@microsoft.com>
net: mana: share the EQ pool across a queue-set swap

This commit makes the EQ pool port-owned so that overlapping queue sets
can share EQs instead of requiring allocations of new vectors. It
allocates max_queues slots and tracks populated entries, growing the
pool before creating replacement CQs.

> diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
> --- a/drivers/net/ethernet/microsoft/mana/mana_en.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c

[ ... ]

> +/* Grow the shared EQ pool without replacing live entries. */
> +static int mana_grow_eqs(struct mana_port_context *apc, unsigned int need)
> +{

[ ... ]

> +	for (i = apc->num_eqs; i < need; i++) {
> +		msi = (i + 1) % gc->num_msix_usable;
> +
> +		gic = mana_gd_get_gic(gc, !gc->msi_sharing, &msi);
> +		if (IS_ERR(gic)) {
> +			err = PTR_ERR(gic);
> +			goto out;
> +		}
> +		spec.eq.msix_index = msi;
> +
> +		err = mana_gd_create_mana_eq(gd, &spec, &apc->eqs[i].eq);

[Severity: Medium]
Does this code leak the DMA region handle when queue creation fails? 

The new mana_grow_eqs() function iteratively loops and relies on
mana_gd_create_mana_eq(), but looking at the error path inside
mana_gd_create_mana_eq():

mana_gd_create_mana_eq() {
    ...
    err = mana_gd_create_dma_region(gd, gmi);
    if (err)
        goto out;
    ...
    err = mana_gd_create_eq(gd, spec, true, queue);
    if (err)
        goto out;
    ...
out:
    dev_err(gc->dev, "Failed to create queue type %d of size: %u, err: %d\n",
            spec->type, spec->queue_size, err);
    mana_gd_free_memory(gmi);
free_q:
    kfree(queue);
    return err;
}

If mana_gd_create_eq() fails, execution jumps to the out label, which
calls mana_gd_free_memory() and kfree() but entirely omits calling
mana_gd_destroy_dma_region() for the successfully allocated DMA region.
Since mana_gd_destroy_eq() does not destroy the DMA region either, the
handle mapping remains persistently leaked.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1790795005.git.weh@linux.microsoft.com?part=2

  reply	other threads:[~2026-10-10 14:42 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 14:41 [PATCH net-next v6 00/13] net: mana: reconfigure by replacing the queue set Wei Hu
2026-10-09 14:41 ` [PATCH net-next v6 01/13] net: mana: add queue-set allocation and teardown helpers Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 02/13] net: mana: share the EQ pool across a queue-set swap Wei Hu
2026-10-10 14:42   ` sashiko-bot [this message]
2026-10-09 14:41 ` [PATCH net-next v6 03/13] net: mana: keep per-queue statistics in the port context Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-13 10:26     ` [EXTERNAL] " Wei Hu
2026-10-09 14:41 ` [PATCH net-next v6 04/13] net: mana: swap queue sets in mana_set_channels Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-13 10:39     ` [EXTERNAL] " Wei Hu
2026-10-09 14:41 ` [PATCH net-next v6 05/13] net: mana: swap queue sets in mana_set_ringparam Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 06/13] net: mana: swap queue sets in mana_set_priv_flags Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 07/13] net: mana: swap queue sets in mana_change_mtu Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-13 11:11     ` [EXTERNAL] " Wei Hu
2026-10-09 14:41 ` [PATCH net-next v6 08/13] net: mana: swap queue sets in mana_xdp_set Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 09/13] net: mana: do not bail out of mana_detach on dealloc failure Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 10/13] net: mana: release EQs left idle by a channel-count reduction Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 11/13] net: mana: keep a user-configured RSS table across a queue rebuild Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 12/13] net: mana: keep the surviving queues when the channel count is reduced Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 13/13] net: mana: keep the existing queues when the channel count is raised Wei Hu
2026-10-10 16:28 ` [PATCH net-next v6 00/13] net: mana: reconfigure by replacing the queue set Simon Horman

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=sashiko-outbox-166658@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=weh@linux.microsoft.com \
    /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