]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bnx2x: fix potential memory leak in bnx2x_alloc_mem_bp()
authorAbdun Nihaal <nihaal@cse.iitm.ac.in>
Sat, 20 Jun 2026 06:23:50 +0000 (11:53 +0530)
committerJakub Kicinski <kuba@kernel.org>
Tue, 23 Jun 2026 01:39:12 +0000 (18:39 -0700)
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>
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>
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c

index 19e078479b0d4a9c2b334c7bd4c1c10a940400c6..5b2640bd31c3a35d1e1e4d2f4d64195609282ca1 100644 (file)
@@ -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)