Skip to contentSkip to conversation

net: pch_gbe: fix potential memleak in pch_gbe_tx_queue()

PATCH Applied Wang Hai 2 participants 2 messages Nov 17, 2022 – Nov 18, 2022

Subsystems (2)
lore
Share & tools
lore

Wang Hai

author
#0 lore raw

PATCH 1/1 net: pch_gbe: fix potential memleak in pch_gbe_tx_queue()

In pch_gbe_xmit_frame(), NETDEV_TX_OK will be returned whether pch_gbe_tx_queue() sends data successfully or not, so pch_gbe_tx_queue() needs to free skb before returning. But pch_gbe_tx_queue() returns without freeing skb in case of dma_map_single() fails. Add dev_kfree_skb_any() to fix it.

Fixes 77555ee72282 ("net: Add Gigabit Ethernet driver of Topcliff PCH")
---
 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +1 -0
index 3f2c30184752..c9ae47128a07 100644
@@ -1143,6 +1143,7 @@ static void pch_gbe_tx_queue(struct pch_gbe_adapter *adapter,
 		buffer_info->dma = 0;
 		buffer_info->time_stamp = 0;
 		tx_ring->next_to_use = ring_num;
+		dev_kfree_skb_any(skb);
 		return;
 	}
 	buffer_info->mapped = true;
Signature · 1 line
2.17.1
#1 lore raw
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:

Quoted 10 lines · On Thu, 17 Nov 2022 14:55:27 +0800 you wrote:

In pch_gbe_xmit_frame(), NETDEV_TX_OK will be returned whether pch_gbe_tx_queue() sends data successfully or not, so pch_gbe_tx_queue() needs to free skb before returning. But pch_gbe_tx_queue() returns without freeing skb in case of dma_map_single() fails. Add dev_kfree_skb_any() to fix it.

Fixes 77555ee72282 ("net: Add Gigabit Ethernet driver of Topcliff PCH")

[...]

Here is the summary with links:
- [net] net: pch_gbe: fix potential memleak in pch_gbe_tx_queue()

    https://git.kernel.org/netdev/net/c/2360f9b8c4e8

You are awesome, thank you!

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