net: systemport: fix potential memory leak in bcm_sysport_xmit()
Subsystems (3)
PATCH 1/1 net: systemport: fix potential memory leak in bcm_sysport_xmit()
The bcm_sysport_xmit() returns NETDEV_TX_OK without freeing skb in case of dma_map_single() fails, add dev_kfree_skb() to fix it.
--- drivers/net/ethernet/broadcom/bcmsysport.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/bcmsysport.c +1 -0
@@ -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_kfree_skb_any (skb); goto out; }
Signature · 1 line
2.17.1
Florian Fainelli
maintainerQuoted 13 lines · Wang Hai
The
bcm_sysport_xmit()returnsNETDEV_TX_OKwithout freeing skb in case ofdma_map_single()fails, adddev_kfree_skb()to fix it.Fixes 80105befdb4b ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver")Signed-off-by Wang Hai <[email protected]>--->
drivers/net/ethernet/broadcom/bcmsysport.c| 1 +1 file changed, 1 insertion(+)drivers/net/ethernet/broadcom/bcmsysport.c +0
-0
drivers/net/ethernet/broadcom/bcmsysport.c static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb, · line 1362
Quoted 4 lines
drivers/net/ethernet/broadcom/bcmsysport.c +1
-0@@ -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_kfree_skb_any (skb);
Since we already have a private counter tracking DMA mapping errors, I would follow what the driver does elsewhere in the transmit path, especially what bcm_sysport_insert_tsb() does, and just use dev_consume_skb_any() here.
Signature · 1 line
Florian
Quoted 9 lines · Florian Fainelli
Quoted 8 lines · Wang Hai
The
bcm_sysport_xmit()returnsNETDEV_TX_OKwithout freeing skb in case ofdma_map_single()fails, adddev_kfree_skb()to fix it.Fixes 80105befdb4b ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver")Signed-off-by Wang Hai <[email protected]>--->
drivers/net/ethernet/broadcom/bcmsysport.c| 1 +1 file changed, 1 insertion(+)
Quoted 12 lines
drivers/net/ethernet/broadcom/bcmsysport.c static netdev_tx_t bcm_sysport_xmit(struct · line 1363
Quoted 10 lines
drivers/net/ethernet/broadcom/bcmsysport.c +1
-0@@ -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_kfree_skb_any(skb);Since we already have a private counter tracking DMA mapping errors, I would follow what the driver does elsewhere in the transmit path, especially what
bcm_sysport_insert_tsb()does, and just usedev_consume_skb_any()here.
Hi, Florian.
Thanks for the suggestion, I've resent the v2 version of this one as well.
[PATCH v2 net] net: systemport: fix potential memory leak in bcm_sysport_xmit()
Jakub Kicinski
maintainerQuoted 6 lines · On Mon, 14 Oct 2024 09:59:27 -0700 Florian Fainelli wrote:
Quoted 6 lines
drivers/net/ethernet/broadcom/bcmsysport.c +0
-0@@ -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",
Quoted 8 lines
drivers/net/ethernet/broadcom/bcmsysport.c static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb, · line 1362
Quoted 3 lines
drivers/net/ethernet/broadcom/bcmsysport.c +1
-0skb->data, skb_len); ret =NETDEV_TX_OK ; +dev_kfree_skb_any (skb);Since we already have a private counter tracking DMA mapping errors, I would follow what the driver does elsewhere in the transmit path, especially what
bcm_sysport_insert_tsb()does, and just usedev_consume_skb_any()here.
Are you saying that if the packet drop is accounted is some statistics we should not inform drop monitor about it? 🤔️
That wasn't my understanding of kfree_skb vs consume_skb..
Florian Fainelli
maintainerQuoted 16 lines · Jakub Kicinski
Quoted 6 lines · On Mon, 14 Oct 2024 09:59:27 -0700 Florian Fainelli wrote:
Quoted 6 lines
drivers/net/ethernet/broadcom/bcmsysport.c +0
-0@@ -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",Quoted 8 lines
drivers/net/ethernet/broadcom/bcmsysport.c static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb, · line 1362
Quoted 3 lines
drivers/net/ethernet/broadcom/bcmsysport.c +1
-0skb->data, skb_len); ret =NETDEV_TX_OK ; +dev_kfree_skb_any (skb);Since we already have a private counter tracking DMA mapping errors, I would follow what the driver does elsewhere in the transmit path, especially what
bcm_sysport_insert_tsb()does, and just usedev_consume_skb_any()here.
Quoted 3 lines
Are you saying that if the packet drop is accounted is some statistics we should not inform drop monitor about it? 🤔️
That wasn't my understanding ofkfree_skbvsconsume_skb..
Yes that's my reasoning here, now given that we have had packet drops on transmit that took forever to track down, maybe I better retract that statement and go with v1.
Signature · 1 line
Florian
Jakub Kicinski
maintainerQuoted 5 lines · On Tue, 15 Oct 2024 11:07:29 -0700 Florian Fainelli wrote:
Quoted 5 lines
Quoted 4 lines
Since we already have a private counter tracking DMA mapping errors, I would follow what the driver does elsewhere in the transmit path, especially what
bcm_sysport_insert_tsb()does, and just usedev_consume_skb_any()here.
Quoted 7 lines
Quoted 3 lines
Are you saying that if the packet drop is accounted is some statistics we should not inform drop monitor about it? 🤔️
That wasn't my understanding ofkfree_skbvsconsume_skb..Yes that's my reasoning here, now given that we have had packet drops on transmit that took forever to track down, maybe I better retract that statement and go with v1.
Sounds good, we can apply v1. Would you like to ack/review here?
Florian Fainelli
maintainerQuoted 10 lines · Jakub Kicinski
Quoted 9 lines · On Tue, 15 Oct 2024 11:07:29 -0700 Florian Fainelli wrote:
Quoted 8 lines
Quoted 4 lines
Since we already have a private counter tracking DMA mapping errors, I would follow what the driver does elsewhere in the transmit path, especially what
bcm_sysport_insert_tsb()does, and just usedev_consume_skb_any()here.Are you saying that if the packet drop is accounted is some statistics we should not inform drop monitor about it? 🤔️
That wasn't my understanding ofkfree_skbvsconsume_skb..
Quoted 6 lines
Quoted 3 lines
Yes that's my reasoning here, now given that we have had packet drops on transmit that took forever to track down, maybe I better retract that statement and go with v1.
Sounds good, we can apply v1. Would you like to ack/review here?
Yes, now done, thanks!
Signature · 1 line
Florian
Jakub Kicinski
maintainerQuoted 7 lines · On Tue, 15 Oct 2024 16:55:59 -0700 Florian Fainelli wrote:
Quoted 5 lines
Quoted 3 lines
Yes that's my reasoning here, now given that we have had packet drops on transmit that took forever to track down, maybe I better retract that statement and go with v1.
Sounds good, we can apply v1. Would you like to ack/review here?
Yes, now done, thanks!
I'm having bad luck waiting for people today :)
Pushed exactly 6min before you responded..
Quoted 5 lines · Wang Hai
The
bcm_sysport_xmit()returnsNETDEV_TX_OKwithout freeing skb in case ofdma_map_single()fails, adddev_kfree_skb()to fix it.Fixes 80105befdb4b ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver")Signed-off-by Wang Hai <[email protected]>
Signature · 1 line
Florian