net: altera-tse: fix skb leak on DMA mapping error in tse_start_xmit()
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.
--- drivers/net/ethernet/altera/altera_tse_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/altera/altera_tse_main.c +1 -0
@@ -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
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 intse_start_xmit(), the function returnsNETDEV_TX_OKwithout freeing the skb. SinceNETDEV_TX_OKtells 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