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)
commitd1000fd7995e51deec872d154e0a40d82f7a539f
treec09e37a810e3e5b708b14c5f98ba55d26545b10c
parentd1ad8fb2ac6a1afb71dc22d9ae8efb4dda96c824
bnxt: fix memory leak in bnxt_queue_mem_alloc error cases

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