mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
bnx2x: fix potential memory leak in bnx2x_alloc_mem_bp()
commita986fde914upstream. 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:15192a8cf8("bnx2x: Split the FP structure") Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20260620062402.89549-1-nihaal@cse.iitm.ac.in Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
54d73f18f8
commit
5576ee19a6
@@ -4752,6 +4752,7 @@ int bnx2x_alloc_mem_bp(struct bnx2x *bp)
|
||||
fp = kcalloc(bp->fp_array_size, sizeof(*fp), GFP_KERNEL);
|
||||
if (!fp)
|
||||
goto alloc_err;
|
||||
bp->fp = fp;
|
||||
for (i = 0; i < bp->fp_array_size; i++) {
|
||||
fp[i].tpa_info =
|
||||
kcalloc(ETH_MAX_AGGREGATION_QUEUES_E1H_E2,
|
||||
@@ -4760,8 +4761,6 @@ int bnx2x_alloc_mem_bp(struct bnx2x *bp)
|
||||
goto alloc_err;
|
||||
}
|
||||
|
||||
bp->fp = fp;
|
||||
|
||||
/* allocate sp objs */
|
||||
bp->sp_objs = kcalloc(bp->fp_array_size, sizeof(struct bnx2x_sp_objs),
|
||||
GFP_KERNEL);
|
||||
|
||||
Reference in New Issue
Block a user