* [PATCH net] bnx2x: fix potential memory leak in bnx2x_alloc_mem_bp()
@ 2026-06-20 6:23 Abdun Nihaal
2026-06-22 13:05 ` Simon Horman
2026-06-23 1:50 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 4+ messages in thread
From: Abdun Nihaal @ 2026-06-20 6:23 UTC (permalink / raw)
To: skalluru
Cc: Abdun Nihaal, manishc, andrew+netdev, davem, edumazet, kuba,
pabeni, netdev, linux-kernel, barak, stable
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.
Cc: stable@vger.kernel.org
Fixes: 15192a8cf8a8 ("bnx2x: Split the FP structure")
Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
---
Compile tested only. Issue found using static analysis.
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 19e078479b0d..5b2640bd31c3 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -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)
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net] bnx2x: fix potential memory leak in bnx2x_alloc_mem_bp()
2026-06-20 6:23 [PATCH net] bnx2x: fix potential memory leak in bnx2x_alloc_mem_bp() Abdun Nihaal
@ 2026-06-22 13:05 ` Simon Horman
2026-06-23 1:41 ` Jakub Kicinski
2026-06-23 1:50 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: Simon Horman @ 2026-06-22 13:05 UTC (permalink / raw)
To: Abdun Nihaal
Cc: skalluru, manishc, andrew+netdev, davem, edumazet, kuba, pabeni,
netdev, linux-kernel, barak, stable
On Sat, Jun 20, 2026 at 11:53:50AM +0530, Abdun Nihaal wrote:
> 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.
>
> Cc: stable@vger.kernel.org
> Fixes: 15192a8cf8a8 ("bnx2x: Split the FP structure")
> Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
> ---
> Compile tested only. Issue found using static analysis.
Reviewed-by: Simon Horman <horms@kernel.org>
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.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH net] bnx2x: fix potential memory leak in bnx2x_alloc_mem_bp()
2026-06-22 13:05 ` Simon Horman
@ 2026-06-23 1:41 ` Jakub Kicinski
0 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2026-06-23 1:41 UTC (permalink / raw)
To: Simon Horman
Cc: Abdun Nihaal, skalluru, manishc, andrew+netdev, davem, edumazet,
pabeni, netdev, linux-kernel, barak, stable
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...
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] bnx2x: fix potential memory leak in bnx2x_alloc_mem_bp()
2026-06-20 6:23 [PATCH net] bnx2x: fix potential memory leak in bnx2x_alloc_mem_bp() Abdun Nihaal
2026-06-22 13:05 ` Simon Horman
@ 2026-06-23 1:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-06-23 1:50 UTC (permalink / raw)
To: Abdun Nihaal
Cc: skalluru, manishc, andrew+netdev, davem, edumazet, kuba, pabeni,
netdev, linux-kernel, barak, stable
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
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_fastpath allocated earlier, as it is not linked to the
> bp structure yet. Fix that by linking it immediately after allocation.
>
> Cc: stable@vger.kernel.org
> Fixes: 15192a8cf8a8 ("bnx2x: Split the FP structure")
> Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
>
> [...]
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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-23 1:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-20 6:23 [PATCH net] bnx2x: fix potential memory leak in bnx2x_alloc_mem_bp() Abdun Nihaal
2026-06-22 13:05 ` Simon Horman
2026-06-23 1:41 ` Jakub Kicinski
2026-06-23 1:50 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox