]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bnxt: fix memory leak in bnxt_queue_mem_alloc error cases
authorWill Chen <will.chen.tty@gmail.com>
Wed, 29 Jul 2026 22:01:31 +0000 (15:01 -0700)
committerJakub Kicinski <kuba@kernel.org>
Mon, 3 Aug 2026 21:30:25 +0000 (14:30 -0700)
There is a small memory leak in bnxt_queue_mem_alloc:
when bnxt_alloc_rx_agg_bmap() succeeds
but bnxt_alloc_one_tpa_info() later fails,
the rx_agg_bmap allocated by bnxt_alloc_rx_agg_bmap()
is not freed in the fallthrough cleanup cases.

Free the rx_agg_bmap in the err_free_rx_agg_ring case
and initialize clone->rx_agg_bmap = NULL earlier in the function
to allow for safe fallthrough.

Fixes: bd649c5cc958 ("bnxt_en: handle tpa_info in queue API implementation")
Signed-off-by: Will Chen <will.chen.tty@gmail.com>
Reviewed-by: Joe Damato <joe@dama.to>
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
Link: https://patch.msgid.link/20260729220132.1256924-1-will.chen.tty@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c

index 7513618793daf3972acf339481fb3b85470069a2..004ef99f4530687d50c87e828816866464e3e6b8 100644 (file)
@@ -16217,6 +16217,7 @@ static int bnxt_queue_mem_alloc(struct net_device *dev,
        clone->rx_next_cons = 0;
        clone->need_head_pool = false;
        clone->rx_page_size = qcfg->rx_page_size;
+       clone->rx_agg_bmap = NULL;
 
        rc = bnxt_alloc_rx_page_pool(bp, clone, rxr->page_pool->p.nid);
        if (rc)
@@ -16269,6 +16270,8 @@ err_free_tpa_info:
        bnxt_free_one_tpa_info(bp, clone);
 err_free_rx_agg_ring:
        bnxt_free_ring(bp, &clone->rx_agg_ring_struct.ring_mem);
+       kfree(clone->rx_agg_bmap);
+       clone->rx_agg_bmap = NULL;
 err_free_rx_ring:
        bnxt_free_ring(bp, &clone->rx_ring_struct.ring_mem);
 err_rxq_info_unreg: