Skip to contentSkip to conversation

net/sun3_82586: fix potential memory leak in sun3_82586_send_packet()

PATCH Applied Wang Hai 3 participants 3 messages Oct 15, 2024 – Oct 20, 2024

Subsystems (3)
lore
Share & tools
lore

Wang Hai

author
#0 lore raw

PATCH 1/1 net/sun3_82586: fix potential memory leak in sun3_82586_send_packet()

The sun3_82586_send_packet() returns NETDEV_TX_OK without freeing skb in case of skb->len being too long, add dev_kfree_skb() to fix it.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
---
 drivers/net/ethernet/i825xx/sun3_82586.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/i825xx/sun3_82586.c +1 -0
index f2d4669c81cf..58a3d28d938c 100644
@@ -1012,6 +1012,7 @@ sun3_82586_send_packet(struct sk_buff *skb, struct net_device *dev)
 	if(skb->len > XMIT_BUFF_SIZE)
 	{
 		printk("%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n",dev->name,XMIT_BUFF_SIZE,skb->len);
+		dev_kfree_skb(skb);
 		return NETDEV_TX_OK;
 	}
 
Signature · 1 line
2.17.1
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Wang Hai

The sun3_82586_send_packet() returns NETDEV_TX_OK without freeing skb in case of skb->len being too long, add dev_kfree_skb() to fix it.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
---
 drivers/net/ethernet/i825xx/sun3_82586.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/i825xx/sun3_82586.c +0 -0
index f2d4669c81cf..58a3d28d938c 100644

drivers/net/ethernet/i825xx/sun3_82586.c sun3_82586_send_packet(struct sk_buff *skb, struct net_device *dev) · line 1017

Quoted 6 lines
drivers/net/ethernet/i825xx/sun3_82586.c +1 -0
@@ -1012,6 +1012,7 @@ sun3_82586_send_packet(struct sk_buff *skb, struct net_device *dev)
 	if(skb->len > XMIT_BUFF_SIZE)
 	{
 		printk("%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n",dev->name,XMIT_BUFF_SIZE,skb->len);
+		dev_kfree_skb(skb);
 		return NETDEV_TX_OK;
 	}

Thanks,

I agree that:
* This code-change is correct,
* and in keeping with other code in this function.
* And I agree that this problem goes back to the beginning of git history

#2 lore raw
In reply to Wang Hai
This patch was applied to netdev/net.git (main) by Andrew Lunn <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Andrew Lunn <[email protected]>:

Quoted 8 lines · On Tue, 15 Oct 2024 22:41:48 +0800 you wrote:

The sun3_82586_send_packet() returns NETDEV_TX_OK without freeing skb in case of skb->len being too long, add dev_kfree_skb() to fix it.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
---
 drivers/net/ethernet/i825xx/sun3_82586.c | 1 +
 1 file changed, 1 insertion(+)

Here is the summary with links:
- [net] net/sun3_82586: fix potential memory leak in sun3_82586_send_packet()

    https://git.kernel.org/netdev/net/c/2cb3f56e827a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html