[PATCH v2 net] net: systemport: fix potential memory leak in bcm_sysport_xmit()

Wang Hai posted 1 patch 1 month, 1 week ago
drivers/net/ethernet/broadcom/bcmsysport.c | 1 +
1 file changed, 1 insertion(+)
[PATCH v2 net] net: systemport: fix potential memory leak in bcm_sysport_xmit()
Posted by Wang Hai 1 month, 1 week ago
The bcm_sysport_xmit() returns NETDEV_TX_OK without freeing skb
in case of dma_map_single() fails, add dev_consume_skb_any() to fix it.

Fixes: 80105befdb4b ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver")
Signed-off-by: Wang Hai <wanghai38@huawei.com>
---
v1->v2: replace dev_kfree_skb_any() with dev_consume_skb_any()
 drivers/net/ethernet/broadcom/bcmsysport.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index c9faa8540859..cc0244515304 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -1359,6 +1359,7 @@ static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb,
 		netif_err(priv, tx_err, dev, "DMA map failed at %p (len=%d)\n",
 			  skb->data, skb_len);
 		ret = NETDEV_TX_OK;
+		dev_consume_skb_any(skb);
 		goto out;
 	}
 
-- 
2.17.1
Re: [PATCH v2 net] net: systemport: fix potential memory leak in bcm_sysport_xmit()
Posted by Jakub Kicinski 1 month, 1 week ago
On Tue, 15 Oct 2024 22:35:58 +0800 Wang Hai wrote:
> The bcm_sysport_xmit() returns NETDEV_TX_OK without freeing skb
> in case of dma_map_single() fails, add dev_consume_skb_any() to fix it.

Technically you posted it 16min too early (23h 44min) and I'm not sure
this is better than v1, see the discussion there. So I'm discarding
this version.