bnx2x: fix potential memory leak in bnx2x_alloc_mem_bp()
PATCH 1/1 bnx2x: fix potential memory leak in bnx2x_alloc_mem_bp()
If the allocation of fp[i].tpa_info fails, the error path will not free the struct bnx2x_fastpath allocated earlier, as it is not linked to the bp structure yet. Fix that by linking it immediately after allocation.
---
Compile tested only. Issue found using static analysis.
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +1 -2
@@ -4748,6 +4748,7 @@ int bnx2x_alloc_mem_bp(struct bnx2x *bp) fp =kzalloc_objs (*fp, bp->fp_array_size);if (!fp) goto alloc_err; + bp->fp = fp;for (i =0 ; i < bp->fp_array_size; i++) { fp[i].tpa_info = kzalloc_objs(struct bnx2x_agg_info,
@@ -4756,8 +4757,6 @@ int bnx2x_alloc_mem_bp(struct bnx2x *bp) goto alloc_err; } - bp->fp = fp; -/* allocate sp objs */ bp->sp_objs = kzalloc_objs(struct bnx2x_sp_objs, bp->fp_array_size);if (!bp->sp_objs)
Signature · 1 line
2.43.0
Quoted 9 lines · Abdun Nihaal
If the allocation of fp[i].tpa_info fails, the error path will not free the struct
bnx2x_fastpathallocated earlier, as it is not linked to the bp structure yet. Fix that by linking it immediately after allocation.Fixes 15192a8cf8a8 ("bnx2x: Split the FP structure")Signed-off-by Abdun Nihaal <[email protected]>---
Compile tested only. Issue found using static analysis.
FTR, there is an AI-generated review of this patch available on sashiko.dev. While I don't think that should effect the progress of this patch you may want to consider it in the context of follow-up.
Jakub Kicinski
maintainerQuoted 3 lines · On Mon, 22 Jun 2026 14:05:15 +0100 Simon Horman wrote:
FTR, there is an AI-generated review of this patch available on sashiko.dev. While I don't think that should effect the progress of this patch you may want to consider it in the context of follow-up.
TBH it seems like an adjacent enough issue to me, but okay...
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Sat, 20 Jun 2026 11:53:50 +0530 you wrote:
If the allocation of fp[i].tpa_info fails, the error path will not free the struct
bnx2x_fastpathallocated earlier, as it is not linked to the bp structure yet. Fix that by linking it immediately after allocation.Fixes 15192a8cf8a8 ("bnx2x: Split the FP structure")Signed-off-by Abdun Nihaal <[email protected]>[...]
Here is the summary with links:
- [net] bnx2x: fix potential memory leak in bnx2x_alloc_mem_bp()
https://git.kernel.org/netdev/net/c/a986fde914d8
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html