netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 net] be2net: fix potential memory leak in be_xmit()
@ 2024-10-15 14:48 Wang Hai
  2024-10-16 19:00 ` Simon Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Wang Hai @ 2024-10-15 14:48 UTC (permalink / raw)
  To: ajit.khaparde, horms, sriharsha.basavapatna, somnath.kotur, davem,
	edumazet, kuba, pabeni, VenkatKumar.Duvvuru, zhangxiaoxu5
  Cc: netdev, linux-kernel, wanghai38

The be_xmit() returns NETDEV_TX_OK without freeing skb
in case of be_xmit_enqueue() fails, add dev_kfree_skb_any() to fix it.

Fixes: 760c295e0e8d ("be2net: Support for OS2BMC.")
Signed-off-by: Wang Hai <wanghai38@huawei.com>
---
v1->v2: Add label drop_skb for dev_kfree_skb_any()
 drivers/net/ethernet/emulex/benet/be_main.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index a8596ebcdfd6..875fe379eea2 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -1381,10 +1381,8 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev)
 	be_get_wrb_params_from_skb(adapter, skb, &wrb_params);
 
 	wrb_cnt = be_xmit_enqueue(adapter, txo, skb, &wrb_params);
-	if (unlikely(!wrb_cnt)) {
-		dev_kfree_skb_any(skb);
-		goto drop;
-	}
+	if (unlikely(!wrb_cnt))
+		goto drop_skb;
 
 	/* if os2bmc is enabled and if the pkt is destined to bmc,
 	 * enqueue the pkt a 2nd time with mgmt bit set.
@@ -1393,7 +1391,7 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev)
 		BE_WRB_F_SET(wrb_params.features, OS2BMC, 1);
 		wrb_cnt = be_xmit_enqueue(adapter, txo, skb, &wrb_params);
 		if (unlikely(!wrb_cnt))
-			goto drop;
+			goto drop_skb;
 		else
 			skb_get(skb);
 	}
@@ -1407,6 +1405,8 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev)
 		be_xmit_flush(adapter, txo);
 
 	return NETDEV_TX_OK;
+drop_skb:
+	dev_kfree_skb_any(skb);
 drop:
 	tx_stats(txo)->tx_drv_drops++;
 	/* Flush the already enqueued tx requests */
-- 
2.17.1


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

* Re: [PATCH v2 net] be2net: fix potential memory leak in be_xmit()
  2024-10-15 14:48 [PATCH v2 net] be2net: fix potential memory leak in be_xmit() Wang Hai
@ 2024-10-16 19:00 ` Simon Horman
  2024-10-18  5:28 ` Kalesh Anakkur Purayil
  2024-10-20 14:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2024-10-16 19:00 UTC (permalink / raw)
  To: Wang Hai
  Cc: ajit.khaparde, sriharsha.basavapatna, somnath.kotur, davem,
	edumazet, kuba, pabeni, VenkatKumar.Duvvuru, zhangxiaoxu5, netdev,
	linux-kernel

On Tue, Oct 15, 2024 at 10:48:02PM +0800, Wang Hai wrote:
> The be_xmit() returns NETDEV_TX_OK without freeing skb
> in case of be_xmit_enqueue() fails, add dev_kfree_skb_any() to fix it.
> 
> Fixes: 760c295e0e8d ("be2net: Support for OS2BMC.")
> Signed-off-by: Wang Hai <wanghai38@huawei.com>
> ---
> v1->v2: Add label drop_skb for dev_kfree_skb_any()

Thanks for the update.

Reviewed-by: Simon Horman <horms@kernel.org>

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

* Re: [PATCH v2 net] be2net: fix potential memory leak in be_xmit()
  2024-10-15 14:48 [PATCH v2 net] be2net: fix potential memory leak in be_xmit() Wang Hai
  2024-10-16 19:00 ` Simon Horman
@ 2024-10-18  5:28 ` Kalesh Anakkur Purayil
  2024-10-20 14:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Kalesh Anakkur Purayil @ 2024-10-18  5:28 UTC (permalink / raw)
  To: Wang Hai
  Cc: ajit.khaparde, horms, sriharsha.basavapatna, somnath.kotur, davem,
	edumazet, kuba, pabeni, VenkatKumar.Duvvuru, zhangxiaoxu5, netdev,
	linux-kernel

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

On Tue, Oct 15, 2024 at 8:18 PM Wang Hai <wanghai38@huawei.com> wrote:
>
> The be_xmit() returns NETDEV_TX_OK without freeing skb
> in case of be_xmit_enqueue() fails, add dev_kfree_skb_any() to fix it.
>
> Fixes: 760c295e0e8d ("be2net: Support for OS2BMC.")
> Signed-off-by: Wang Hai <wanghai38@huawei.com>
LGTM
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

-- 
Regards,
Kalesh A P

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

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

* Re: [PATCH v2 net] be2net: fix potential memory leak in be_xmit()
  2024-10-15 14:48 [PATCH v2 net] be2net: fix potential memory leak in be_xmit() Wang Hai
  2024-10-16 19:00 ` Simon Horman
  2024-10-18  5:28 ` Kalesh Anakkur Purayil
@ 2024-10-20 14:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-10-20 14:50 UTC (permalink / raw)
  To: Wang Hai
  Cc: ajit.khaparde, horms, sriharsha.basavapatna, somnath.kotur, davem,
	edumazet, kuba, pabeni, VenkatKumar.Duvvuru, zhangxiaoxu5, netdev,
	linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Andrew Lunn <andrew@lunn.ch>:

On Tue, 15 Oct 2024 22:48:02 +0800 you wrote:
> The be_xmit() returns NETDEV_TX_OK without freeing skb
> in case of be_xmit_enqueue() fails, add dev_kfree_skb_any() to fix it.
> 
> Fixes: 760c295e0e8d ("be2net: Support for OS2BMC.")
> Signed-off-by: Wang Hai <wanghai38@huawei.com>
> ---
> v1->v2: Add label drop_skb for dev_kfree_skb_any()
>  drivers/net/ethernet/emulex/benet/be_main.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)

Here is the summary with links:
  - [v2,net] be2net: fix potential memory leak in be_xmit()
    https://git.kernel.org/netdev/net/c/e4dd8bfe0f6a

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] 4+ messages in thread

end of thread, other threads:[~2024-10-20 14:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-15 14:48 [PATCH v2 net] be2net: fix potential memory leak in be_xmit() Wang Hai
2024-10-16 19:00 ` Simon Horman
2024-10-18  5:28 ` Kalesh Anakkur Purayil
2024-10-20 14:50 ` patchwork-bot+netdevbpf

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).