Skip to contentSkip to conversation

net: xilinx: axienet: fix potential memory leak in axienet_start_xmit()

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

Subsystems (4)
lore
Share & tools
lore

Wang Hai

author
#0 lore raw

PATCH 1/1 net: xilinx: axienet: fix potential memory leak in axienet_start_xmit()

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

Fixes 71791dc8bdea ("net: axienet: Check for DMA mapping errors")
---
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +2 -0
index ea7d7c03f48e..53cf1a927278 100644
@@ -1046,6 +1046,7 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
 		if (net_ratelimit())
 			netdev_err(ndev, "TX DMA mapping error\n");
 		ndev->stats.tx_dropped++;
+		dev_kfree_skb_any(skb);
 		return NETDEV_TX_OK;
 	}
 	desc_set_phys_addr(lp, phys, cur_p);
@@ -1066,6 +1067,7 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
 			ndev->stats.tx_dropped++;
 			axienet_free_tx_chain(lp, orig_tail_ptr, ii + 1,
 					      true, NULL, 0);
+			dev_kfree_skb_any(skb);
 			return NETDEV_TX_OK;
 		}
 		desc_set_phys_addr(lp, phys, cur_p);
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines

-----Original Message-----
From: Wang Hai <[email protected]>
Sent: Monday, October 14, 2024 8:07 PM
To: Pandey, Radhey Shyam <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]
Subject: [PATCH net] net: xilinx: axienet: fix potential memory leak in axienet_start_xmit()

Quoted 5 lines

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

Fixes 71791dc8bdea ("net: axienet: Check for DMA mapping errors")

Thanks!

Quoted 29 lines
---
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1 -0
index ea7d7c03f48e..53cf1a927278 100644
@@ -1046,6 +1046,7 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device
 *ndev)
 		if (net_ratelimit())
 			netdev_err(ndev, "TX DMA mapping error\n");
 		ndev->stats.tx_dropped++;
+		dev_kfree_skb_any(skb);
 		return NETDEV_TX_OK;
 	}
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1 -0
 	desc_set_phys_addr(lp, phys, cur_p);
@@ -1066,6 +1067,7 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device
 *ndev)
 			ndev->stats.tx_dropped++;
 			axienet_free_tx_chain(lp, orig_tail_ptr, ii + 1,
 					      true, NULL, 0);
+			dev_kfree_skb_any(skb);
 			return NETDEV_TX_OK;
 		}

desc_set_phys_addr(lp, phys, cur_p);
--
2.17.1

#2 lore raw
In reply to Wang Hai
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 Mon, 14 Oct 2024 22:37:04 +0800 you wrote:

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

Fixes 71791dc8bdea ("net: axienet: Check for DMA mapping errors")
---
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 ++
 1 file changed, 2 insertions(+)

Here is the summary with links:
- [net] net: xilinx: axienet: fix potential memory leak in axienet_start_xmit()

    https://git.kernel.org/netdev/net/c/99714e37e833

You are awesome, thank you!

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