Re: [PATCH v2] bnx2x: fix resource leaks in bnx2x_init_one() error paths
From: Simon Horman
Date: Thu Jun 11 2026 - 11:33:35 EST
On Tue, Jun 09, 2026 at 03:46:10PM +0800, Haoxiang Li wrote:
> bnx2x_init_one() falls through to the common memory cleanup path for
> several failures after probe has already acquired additional resources.
>
> If register_netdev() fails after bnx2x_set_int_mode(), MSI/MSI-X remains
> enabled. If later failures happen after bnx2x_iov_init_one(), PF SR-IOV
> state can be left allocated. Also, failures after bnx2x_vfpf_acquire()
> must release the PF resources before freeing the VF-PF mailbox allocated
> by bnx2x_vf_pci_alloc().
>
> Add error labels matching the resource acquisition order so probe failure
> disables MSI/MSI-X, removes SR-IOV state, releases VF-PF resources,
> deallocates VF PCI resources, and then frees the common driver memory.
> Also clear PCI drvdata before freeing the netdev on probe failure.
>
> Fixes: 6411280ac94d ("bnx2x: Segregate SR-IOV code")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Haoxiang Li <lihaoxiang@xxxxxxxxxxxxxxxx>
> ---
> Changes in v2:
> - Unwind all resources acquired by bnx2x_init_one() on failure
> - Clear PCI drvdata before freeing the netdev on probe failure.
> - Modify the commit title and message.
Reviewed-by: Simon Horman <horms@xxxxxxxxxx>
FTR, there is an AI-generated review of this patch available on sashiko.dev.
However, I believe the issue flagged there can be looked at in the context
of possible follow-up and should not impede the progress of this patch.