public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel•org>
To: lihaoxiang@isrc•iscas.ac.cn
Cc: Jakub Kicinski <kuba@kernel•org>,
	skalluru@marvell•com, manishc@marvell•com, andrew+netdev@lunn•ch,
	davem@davemloft•net, edumazet@google•com, pabeni@redhat•com,
	ariele@broadcom•com, netdev@vger•kernel.org,
	linux-kernel@vger•kernel.org, stable@vger•kernel.org
Subject: Re: [PATCH] bnx2x: clean up VF PCI resources on probe failure
Date: Fri,  5 Jun 2026 17:31:47 -0700	[thread overview]
Message-ID: <20260606003146.4001333-2-kuba@kernel.org> (raw)
In-Reply-To: <20260603071729.799370-1-lihaoxiang@isrc.iscas.ac.cn>

This is an AI-generated review of your patch. The human sending this
email says "Sashiko points out other problems with the error path
here, they should all be fixed in one series."
---
bnx2x: clean up VF PCI resources on probe failure

bnx2x_init_one() allocates VF PCI resources by calling bnx2x_vf_pci_alloc(),
but later error paths fall through the common cleanup path without calling
bnx2x_vf_pci_dealloc(). This commit adds a VF-specific error label to fix
the leak.

Fixes: 6411280ac94d ("bnx2x: Segregate SR-IOV code")
Cc: stable@vger•kernel.org
Signed-off-by: Haoxiang Li <lihaoxiang@isrc•iscas.ac.cn>

> diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
> index da0f8c353e6a7..acb0379d94b99 100644
> --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
> +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
[ ... ]
> @@ -13979,7 +13979,7 @@ static int bnx2x_init_one(struct pci_dev *pdev,
>  	rc = register_netdev(dev);
>  	if (rc) {
>  		dev_err(&pdev->dev, "Cannot register net device\n");
> -		goto init_one_freemem;
> +		goto init_one_vf_pci_dealloc;

[Severity: High]
This is a pre-existing issue, but if bnx2x_set_int_mode() succeeds earlier in
bnx2x_init_one(), MSI or MSI-X interrupts are configured. If register_netdev()
subsequently fails, the error path skips disabling these interrupts.

Does this leave the interrupts enabled and leak PCI IRQ vectors since there is
no call to bnx2x_disable_msi() on this error path?

>  	}
>  	BNX2X_DEV_INFO("device name after netdev register %s\n", dev->name);
>  
> @@ -14001,6 +14001,10 @@ static int bnx2x_init_one(struct pci_dev *pdev,
>  
>  	return 0;
>  
> +init_one_vf_pci_dealloc:
> +	if (IS_VF(bp))
> +		bnx2x_vf_pci_dealloc(bp);
> +

[Severity: High]
This isn't a bug introduced by this patch, but adding this mailbox cleanup here
seems to prevent releasing the acquired PF resources.

Earlier in bnx2x_init_one(), if IS_VF(bp) is true, we call bnx2x_vfpf_acquire()
to request resources from the PF. If a failure occurs later in the probe
function, the new error path calls bnx2x_vf_pci_dealloc() which frees the
VF-to-PF mailbox.

Because the mailbox memory is destroyed without first calling
bnx2x_vfpf_release(), does this result in a permanent leak of PF resources
assigned to the VF?

>  init_one_freemem:
>  	bnx2x_free_mem_bp(bp);
-- 
pw-bot: cr

      reply	other threads:[~2026-06-06  0:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-03  7:17 [PATCH] bnx2x: clean up VF PCI resources on probe failure Haoxiang Li
2026-06-06  0:31 ` Jakub Kicinski [this message]

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=20260606003146.4001333-2-kuba@kernel.org \
    --to=kuba@kernel$(echo .)org \
    --cc=andrew+netdev@lunn$(echo .)ch \
    --cc=ariele@broadcom$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=edumazet@google$(echo .)com \
    --cc=lihaoxiang@isrc$(echo .)iscas.ac.cn \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=manishc@marvell$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pabeni@redhat$(echo .)com \
    --cc=skalluru@marvell$(echo .)com \
    --cc=stable@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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