Skip to contentSkip to conversation

net: altera-tse: fix skb leak on DMA mapping error in tse_start_xmit()

PATCH Applied David Carlier 2 participants 2 messages Apr 1 – Apr 3

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: altera-tse: fix skb leak on DMA mapping error in tse_start_xmit()

When dma_map_single() fails in tse_start_xmit(), the function returns NETDEV_TX_OK without freeing the skb. Since NETDEV_TX_OK tells the stack the packet was consumed, the skb is never freed, leaking memory on every DMA mapping failure.

Add dev_kfree_skb_any() before returning to properly free the skb.

Fixes bbd2190ce96d ("Altera TSE: Add main and header file for Altera Ethernet Driver")
---
 drivers/net/ethernet/altera/altera_tse_main.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/altera/altera_tse_main.c +1 -0
index 4342e2d026f8..9eed0be4411e 100644
@@ -570,6 +570,7 @@ static netdev_tx_t tse_start_xmit(struct sk_buff *skb, struct net_device *dev)
 				  DMA_TO_DEVICE);
 	if (dma_mapping_error(priv->device, dma_addr)) {
 		netdev_err(priv->dev, "%s: DMA mapping error\n", __func__);
+		dev_kfree_skb_any(skb);
 		ret = NETDEV_TX_OK;
 		goto out;
 	}
Signature · 1 line
2.53.0
#1 lore raw
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 8 lines · On Wed, 1 Apr 2026 22:12:18 +0100 you wrote:

When dma_map_single() fails in tse_start_xmit(), the function returns NETDEV_TX_OK without freeing the skb. Since NETDEV_TX_OK tells the stack the packet was consumed, the skb is never freed, leaking memory on every DMA mapping failure.

Add dev_kfree_skb_any() before returning to properly free the skb.

[...]

Here is the summary with links:
- net: altera-tse: fix skb leak on DMA mapping error in tse_start_xmit()

    https://git.kernel.org/netdev/net/c/6dede3967619

You are awesome, thank you!

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