* [PATCH net] bnxt_en: Fix auxiliary device leak on early probe failures
@ 2026-11-18 5:07 Changyul Lee
2026-11-18 17:23 ` Joe Damato
0 siblings, 1 reply; 2+ messages in thread
From: Changyul Lee @ 2026-11-18 5:07 UTC (permalink / raw)
To: Michael Chan, Pavan Chebbi
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Vikas Gupta, Andy Gospodarek, Jacob Keller, netdev,
linux-kernel, Changyul Lee
bnxt_init_one() allocates the auxiliary device ID and initializes the
auxiliary devices before bnxt_set_dflt_rings(). If that call,
bnxt_init_int_mode() or the bnxt_pf_wq allocation fails, probe jumps to
init_err_pci_clean, which does not uninitialize the devices or free the
ID. Only init_err_cleanup does. The devices are never released, so their
aux_priv, edev and ulp_tbl allocations and the ID in bnxt_aux_dev_ids are
leaked once free_netdev() frees bp. A VF probed while the PF is down
fails this way each time.
Add an init_err_auxdev label for this cleanup and use it for every
failure after the devices are initialized. On the register_netdev()
failure path the cleanup now runs after bnxt_clear_int_mode(), in the
reverse order of setup.
Fixes: 2e4592dc9bee ("bnxt_en: Change MSIX/NQs allocation policy")
Signed-off-by: Changyul Lee <lcy8047@gmail.com>
---
Found with a static analysis tool we are developing.
Compile-tested only, with x86_64_defconfig plus BNXT and W=1.
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index e78cf7ad3cbc..ba0e458a467f 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -17423,7 +17423,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
netdev_err(bp->dev, "Not enough rings available.\n");
rc = -ENOMEM;
}
- goto init_err_pci_clean;
+ goto init_err_auxdev;
}
bnxt_fw_init_one_p3(bp);
@@ -17435,7 +17435,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
rc = bnxt_init_int_mode(bp);
if (rc)
- goto init_err_pci_clean;
+ goto init_err_auxdev;
/* No TC has been set yet and rings may have been trimmed due to
* limited MSIX, so we re-initialize the TX rings per TC.
@@ -17449,7 +17449,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
if (!bnxt_pf_wq) {
dev_err(&pdev->dev, "Unable to create workqueue.\n");
rc = -ENOMEM;
- goto init_err_pci_clean;
+ goto init_err_auxdev;
}
}
rc = bnxt_init_tc(bp);
@@ -17487,12 +17487,13 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
return 0;
init_err_cleanup:
- bnxt_aux_devices_uninit(bp);
- bnxt_auxdev_id_free(bp, bp->auxdev_id);
bnxt_dl_unregister(bp);
init_err_dl:
bnxt_shutdown_tc(bp);
bnxt_clear_int_mode(bp);
+init_err_auxdev:
+ bnxt_aux_devices_uninit(bp);
+ bnxt_auxdev_id_free(bp, bp->auxdev_id);
init_err_pci_clean:
bnxt_hwrm_func_drv_unrgtr(bp);
base-commit: 2a324a58a084c5cfd7e5a2f55e0786bee170a4a5
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH net] bnxt_en: Fix auxiliary device leak on early probe failures
2026-11-18 5:07 [PATCH net] bnxt_en: Fix auxiliary device leak on early probe failures Changyul Lee
@ 2026-11-18 17:23 ` Joe Damato
0 siblings, 0 replies; 2+ messages in thread
From: Joe Damato @ 2026-11-18 17:23 UTC (permalink / raw)
To: Changyul Lee
Cc: Michael Chan, Pavan Chebbi, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Vikas Gupta,
Andy Gospodarek, Jacob Keller, netdev, linux-kernel
On Wed, Nov 18, 2026 at 12:07:16AM -0500, Changyul Lee wrote:
> bnxt_init_one() allocates the auxiliary device ID and initializes the
> auxiliary devices before bnxt_set_dflt_rings(). If that call,
> bnxt_init_int_mode() or the bnxt_pf_wq allocation fails, probe jumps to
> init_err_pci_clean, which does not uninitialize the devices or free the
> ID. Only init_err_cleanup does. The devices are never released, so their
> aux_priv, edev and ulp_tbl allocations and the ID in bnxt_aux_dev_ids are
> leaked once free_netdev() frees bp. A VF probed while the PF is down
> fails this way each time.
>
> Add an init_err_auxdev label for this cleanup and use it for every
> failure after the devices are initialized. On the register_netdev()
> failure path the cleanup now runs after bnxt_clear_int_mode(), in the
> reverse order of setup.
>
> Fixes: 2e4592dc9bee ("bnxt_en: Change MSIX/NQs allocation policy")
> Signed-off-by: Changyul Lee <lcy8047@gmail.com>
> ---
> Found with a static analysis tool we are developing.
>
> Compile-tested only, with x86_64_defconfig plus BNXT and W=1.
>
> drivers/net/ethernet/broadcom/bnxt/bnxt.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
Reviewed-by: Joe Damato <joe@dama.to>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-18 17:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 5:07 [PATCH net] bnxt_en: Fix auxiliary device leak on early probe failures Changyul Lee
2026-11-18 17:23 ` Joe Damato
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®