Netdev List
 help / color / mirror / Atom feed
* [PATCH net] bnxt: fix memory leak in bnxt_queue_mem_alloc error cases
@ 2026-07-28 19:11 Will Chen
  2026-07-28 19:22 ` Joe Damato
  2026-07-28 19:46 ` Michael Chan
  0 siblings, 2 replies; 3+ messages in thread
From: Will Chen @ 2026-07-28 19:11 UTC (permalink / raw)
  To: Michael Chan, Pavan Chebbi, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Wei, netdev,
	linux-kernel

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.

Simply free the rx_agg_bmap in the err_free_tpa_info case,
as this is the only remaining error path where
rx_agg_bmap is allocated and needs to be freed.

Fixes: bd649c5cc958 ("bnxt_en: handle tpa_info in queue API implementation")
Signed-off-by: Will Chen <will.chen.tty@gmail.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 7513618793da..c30507dd824e 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -16267,6 +16267,8 @@ static int bnxt_queue_mem_alloc(struct net_device *dev,
 
 err_free_tpa_info:
 	bnxt_free_one_tpa_info(bp, clone);
+	kfree(clone->rx_agg_bmap);
+	clone->rx_agg_bmap = NULL;
 err_free_rx_agg_ring:
 	bnxt_free_ring(bp, &clone->rx_agg_ring_struct.ring_mem);
 err_free_rx_ring:

base-commit: 3f1f755366687d051174739fb99f7d560202f60b
-- 
2.53.0-Meta


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] bnxt: fix memory leak in bnxt_queue_mem_alloc error cases
  2026-07-28 19:11 [PATCH net] bnxt: fix memory leak in bnxt_queue_mem_alloc error cases Will Chen
@ 2026-07-28 19:22 ` Joe Damato
  2026-07-28 19:46 ` Michael Chan
  1 sibling, 0 replies; 3+ messages in thread
From: Joe Damato @ 2026-07-28 19:22 UTC (permalink / raw)
  To: Will Chen
  Cc: Michael Chan, Pavan Chebbi, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Wei, netdev,
	linux-kernel

On Tue, Jul 28, 2026 at 12:11:45PM -0700, Will Chen wrote:
> 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.
> 
> Simply free the rx_agg_bmap in theerr_free_tpa_info case,
> as this is the only remaining error path where
> rx_agg_bmap is allocated and needs to be freed.
> 
> Fixes: bd649c5cc958 ("bnxt_en: handle tpa_info in queue API implementation")
> Signed-off-by: Will Chen <will.chen.tty@gmail.com>
> ---
>  drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 ++
>  1 file changed, 2 insertions(+)
>

Reviewed-by: Joe Damato <joe@dama.to>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] bnxt: fix memory leak in bnxt_queue_mem_alloc error cases
  2026-07-28 19:11 [PATCH net] bnxt: fix memory leak in bnxt_queue_mem_alloc error cases Will Chen
  2026-07-28 19:22 ` Joe Damato
@ 2026-07-28 19:46 ` Michael Chan
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Chan @ 2026-07-28 19:46 UTC (permalink / raw)
  To: Will Chen
  Cc: Pavan Chebbi, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, David Wei, netdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1581 bytes --]

On Tue, Jul 28, 2026 at 12:11 PM Will Chen <will.chen.tty@gmail.com> wrote:
>
> 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.
>
> Simply free the rx_agg_bmap in the err_free_tpa_info case,
> as this is the only remaining error path where
> rx_agg_bmap is allocated and needs to be freed.
>
> Fixes: bd649c5cc958 ("bnxt_en: handle tpa_info in queue API implementation")
> Signed-off-by: Will Chen <will.chen.tty@gmail.com>
> ---
>  drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 7513618793da..c30507dd824e 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -16267,6 +16267,8 @@ static int bnxt_queue_mem_alloc(struct net_device *dev,
>
>  err_free_tpa_info:
>         bnxt_free_one_tpa_info(bp, clone);
> +       kfree(clone->rx_agg_bmap);
> +       clone->rx_agg_bmap = NULL;

I think logically, these 2 lines should be moved below under
err_free_rx_agg_ring because it is memory related to the agg ring.  We
may need to initialize clone->rx_agg_bmap = NULL near the top of the
function to be more complete.  Thanks.

>  err_free_rx_agg_ring:
>         bnxt_free_ring(bp, &clone->rx_agg_ring_struct.ring_mem);
>  err_free_rx_ring:
>

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5469 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-28 19:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-28 19:11 [PATCH net] bnxt: fix memory leak in bnxt_queue_mem_alloc error cases Will Chen
2026-07-28 19:22 ` Joe Damato
2026-07-28 19:46 ` Michael Chan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox