linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bnx2x: fix potential memory leak in bnx2x_tpa_stop()
@ 2022-09-30  6:28 Jianglei Nie
  2022-10-03 11:50 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 6+ messages in thread
From: Jianglei Nie @ 2022-09-30  6:28 UTC (permalink / raw)
  To: aelior, skalluru, manishc, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, Jianglei Nie

bnx2x_tpa_stop() allocates a memory chunk from new_data with
bnx2x_frag_alloc(). The new_data should be freed when gets some error.
But when "pad + len > fp->rx_buf_size" is true, bnx2x_tpa_stop() returns
without releasing the new_data, which will lead to a memory leak.

We should free the new_data with bnx2x_frag_free() when "pad + len >
fp->rx_buf_size" is true.

Fixes: 07b0f00964def8af9321cfd6c4a7e84f6362f728 ("bnx2x: fix possible
panic under memory stress")
Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 712b5595bc39..24bfc65e28e1 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -789,6 +789,7 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp,
 			BNX2X_ERR("skb_put is about to fail...  pad %d  len %d  rx_buf_size %d\n",
 				  pad, len, fp->rx_buf_size);
 			bnx2x_panic();
+			bnx2x_frag_free(fp, new_data);
 			return;
 		}
 #endif
-- 
2.25.1


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

* Re: [PATCH] bnx2x: fix potential memory leak in bnx2x_tpa_stop()
  2022-09-30  6:28 [PATCH] bnx2x: fix potential memory leak in bnx2x_tpa_stop() Jianglei Nie
@ 2022-10-03 11:50 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-10-03 11:50 UTC (permalink / raw)
  To: Jianglei Nie
  Cc: aelior, skalluru, manishc, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Fri, 30 Sep 2022 14:28:43 +0800 you wrote:
> bnx2x_tpa_stop() allocates a memory chunk from new_data with
> bnx2x_frag_alloc(). The new_data should be freed when gets some error.
> But when "pad + len > fp->rx_buf_size" is true, bnx2x_tpa_stop() returns
> without releasing the new_data, which will lead to a memory leak.
> 
> We should free the new_data with bnx2x_frag_free() when "pad + len >
> fp->rx_buf_size" is true.
> 
> [...]

Here is the summary with links:
  - bnx2x: fix potential memory leak in bnx2x_tpa_stop()
    https://git.kernel.org/netdev/net/c/b43f9acbb894

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* Re: [PATCH] bnx2x: fix potential memory leak in bnx2x_tpa_stop()
  2022-09-29  2:37 Jianglei Nie
@ 2022-09-29 16:20 ` Jakub Kicinski
  0 siblings, 0 replies; 6+ messages in thread
From: Jakub Kicinski @ 2022-09-29 16:20 UTC (permalink / raw)
  To: Jianglei Nie
  Cc: aelior, skalluru, manishc, davem, edumazet, pabeni, netdev, linux-kernel

On Thu, 29 Sep 2022 10:37:52 +0800 Jianglei Nie wrote:
> Fixes: 07b0f00 ("bnx2x: fix possible panic under memory stress")

sha too short

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

* [PATCH] bnx2x: fix potential memory leak in bnx2x_tpa_stop()
@ 2022-09-29  2:37 Jianglei Nie
  2022-09-29 16:20 ` Jakub Kicinski
  0 siblings, 1 reply; 6+ messages in thread
From: Jianglei Nie @ 2022-09-29  2:37 UTC (permalink / raw)
  To: aelior, skalluru, manishc, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, Jianglei Nie

bnx2x_tpa_stop() allocates a memory chunk from new_data with
bnx2x_frag_alloc(). The new_data should be freed when gets some error.
But when "pad + len > fp->rx_buf_size" is true, bnx2x_tpa_stop() returns
without releasing the new_data, which will lead to a memory leak.

We should free the new_data with bnx2x_frag_free() when "pad + len >
fp->rx_buf_size" is true.

Fixes: 07b0f00 ("bnx2x: fix possible panic under memory stress")
Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 712b5595bc39..24bfc65e28e1 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -789,6 +789,7 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp,
 			BNX2X_ERR("skb_put is about to fail...  pad %d  len %d  rx_buf_size %d\n",
 				  pad, len, fp->rx_buf_size);
 			bnx2x_panic();
+			bnx2x_frag_free(fp, new_data);
 			return;
 		}
 #endif
-- 
2.25.1


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

* Re: [PATCH] bnx2x: fix potential memory leak in bnx2x_tpa_stop()
  2022-09-07  6:51 Jianglei Nie
@ 2022-09-19 21:21 ` Jakub Kicinski
  0 siblings, 0 replies; 6+ messages in thread
From: Jakub Kicinski @ 2022-09-19 21:21 UTC (permalink / raw)
  To: Jianglei Nie
  Cc: aelior, skalluru, manishc, davem, edumazet, pabeni, netdev, linux-kernel

On Wed,  7 Sep 2022 14:51:28 +0800 Jianglei Nie wrote:
> bnx2x_tpa_stop() allocates a memory chunk from new_data with
> bnx2x_frag_alloc(). The new_data should be freed when gets some error.
> But when "pad + len > fp->rx_buf_size" is true, bnx2x_tpa_stop() returns
> without releasing the new_data, which will lead to a memory leak.
> 
> We should free the new_data with bnx2x_frag_free() when "pad + len >
> fp->rx_buf_size" is true.

Please add a Fixes tag and repost.

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

* [PATCH] bnx2x: fix potential memory leak in bnx2x_tpa_stop()
@ 2022-09-07  6:51 Jianglei Nie
  2022-09-19 21:21 ` Jakub Kicinski
  0 siblings, 1 reply; 6+ messages in thread
From: Jianglei Nie @ 2022-09-07  6:51 UTC (permalink / raw)
  To: aelior, skalluru, manishc, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, Jianglei Nie

bnx2x_tpa_stop() allocates a memory chunk from new_data with
bnx2x_frag_alloc(). The new_data should be freed when gets some error.
But when "pad + len > fp->rx_buf_size" is true, bnx2x_tpa_stop() returns
without releasing the new_data, which will lead to a memory leak.

We should free the new_data with bnx2x_frag_free() when "pad + len >
fp->rx_buf_size" is true.

Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 712b5595bc39..24bfc65e28e1 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -789,6 +789,7 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp,
 			BNX2X_ERR("skb_put is about to fail...  pad %d  len %d  rx_buf_size %d\n",
 				  pad, len, fp->rx_buf_size);
 			bnx2x_panic();
+			bnx2x_frag_free(fp, new_data);
 			return;
 		}
 #endif
-- 
2.25.1


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

end of thread, other threads:[~2022-10-03 11:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-30  6:28 [PATCH] bnx2x: fix potential memory leak in bnx2x_tpa_stop() Jianglei Nie
2022-10-03 11:50 ` patchwork-bot+netdevbpf
  -- strict thread matches above, loose matches on Subject: below --
2022-09-29  2:37 Jianglei Nie
2022-09-29 16:20 ` Jakub Kicinski
2022-09-07  6:51 Jianglei Nie
2022-09-19 21:21 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).