net: bcmasp: fix potential memory leak in bcmasp_xmit()
Subsystems (3)
PATCH 1/1 net: bcmasp: fix potential memory leak in bcmasp_xmit()
The bcmasp_xmit() returns NETDEV_TX_OK without freeing skb in case of mapping fails, add dev_kfree_skb() to fix it.
--- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +1 -0
@@ -322,6 +322,7 @@ static netdev_tx_t bcmasp_xmit(struct sk_buff *skb, struct net_device *dev) }/* Rewind so we do not have a hole */ spb_index = intf->tx_spb_index; +dev_kfree_skb (skb);return NETDEV_TX_OK ; }
Signature · 1 line
2.17.1
Florian Fainelli
maintainerQuoted 14 lines · Wang Hai
The
bcmasp_xmit()returnsNETDEV_TX_OKwithout freeing skb in case of mapping fails, adddev_kfree_skb()to fix it.Fixes 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller")Signed-off-by Wang Hai <[email protected]>--- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +0
-0
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c static netdev_tx_t bcmasp_xmit(struct sk_buff *skb, struct net_device *dev) · line 325
Quoted 4 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +1
-0@@ -322,6 +322,7 @@ static netdev_tx_t bcmasp_xmit(struct sk_buff *skb, struct net_device *dev) }/* Rewind so we do not have a hole */ spb_index = intf->tx_spb_index; +dev_kfree_skb (skb);
Similar reasoning to the change proposed to bcmsysport.c, we already have a private counter tracking DMA mapping errors, therefore I would consider using dev_consume_skb_any() here.
Signature · 1 line
Florian
Quoted 10 lines · Florian Fainelli
Quoted 9 lines · Wang Hai
The
bcmasp_xmit()returnsNETDEV_TX_OKwithout freeing skb in case of mapping fails, adddev_kfree_skb()to fix it.Fixes 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller")Signed-off-by Wang Hai <[email protected]>---
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c| 1 +1 file changed, 1 insertion(+)
Quoted 12 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c static netdev_tx_t bcmasp_xmit(struct sk_buff · line 326
Quoted 10 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +1
-0@@ -322,6 +322,7 @@ static netdev_tx_t bcmasp_xmit(struct sk_buff *skb, struct net_device *dev) } /* Rewind so we do not have a hole */ spb_index = intf->tx_spb_index; + dev_kfree_skb(skb);Similar reasoning to the change proposed to
bcmsysport.c, we already have a private counter tracking DMA mapping errors, therefore I would consider usingdev_consume_skb_any()here.
Hi, Florian.
Thanks for the suggestion, I've resent v2.
[PATCH v2 net] net: bcmasp: fix potential memory leak in bcmasp_xmit()
Jakub Kicinski
maintainerQuoted 10 lines · On Mon, 14 Oct 2024 10:14:59 -0700 Florian Fainelli wrote:
Quoted 9 lines · Wang Hai
The
bcmasp_xmit()returnsNETDEV_TX_OKwithout freeing skb in case of mapping fails, adddev_kfree_skb()to fix it.Fixes 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller")Signed-off-by Wang Hai <[email protected]>--- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 1 + 1 file changed, 1 insertion(+)
Quoted 13 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c static netdev_tx_t bcmasp_xmit(struct sk_buff *skb, struct net_device *dev) · line 325
Quoted 9 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +1
-0@@ -322,6 +322,7 @@ static netdev_tx_t bcmasp_xmit(struct sk_buff *skb, struct net_device *dev) }/* Rewind so we do not have a hole */ spb_index = intf->tx_spb_index; +dev_kfree_skb (skb);Similar reasoning to the change proposed to
bcmsysport.c, we already have a private counter tracking DMA mapping errors, therefore I would consider usingdev_consume_skb_any()here.
.. but this one hasn't been pushed and I presume same treatment will apply?
Quoted 5 lines · Wang Hai
The
bcmasp_xmit()returnsNETDEV_TX_OKwithout freeing skb in case of mapping fails, adddev_kfree_skb()to fix it.Fixes 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller")Signed-off-by Wang Hai <[email protected]>
Signature · 1 line
Florian
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:59:01 +0800 you wrote:
The
bcmasp_xmit()returnsNETDEV_TX_OKwithout freeing skb in case of mapping fails, adddev_kfree_skb()to fix it.Fixes 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller")Signed-off-by Wang Hai <[email protected]>--- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 1 + 1 file changed, 1 insertion(+)
Here is the summary with links:
- [net] net: bcmasp: fix potential memory leak in bcmasp_xmit()
https://git.kernel.org/netdev/net/c/fed07d3eb8a8
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html