Skip to contentSkip to conversation

net/bonding: fix memory leak on closing device

PATCH Applied [email protected] 3 participants 5 messages Sep 15, 2021 – Sep 21, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/bonding: fix memory leak on closing device

From: Dapeng Yu <[email protected]>

If the bond device was created by vdev mode, the kvlist was not free after the bond device was closed.

This patch fixes it.

Fixes 144dc4739975 ("net/bonding: fix leak on remove")
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/bonding/rte_eth_bond_pmd.c +3 -2
index a6755661c4..2e96b850fb 100644
@@ -2163,6 +2163,9 @@ bond_ethdev_close(struct rte_eth_dev *dev)
 	 */
 	rte_mempool_free(internals->mode6.mempool);
 
+	if (internals->kvlist != NULL)
+		rte_kvargs_free(internals->kvlist);
+
 	return 0;
 }
 
@@ -3475,8 +3478,6 @@ bond_remove(struct rte_vdev_device *dev)
 		ret = bond_ethdev_stop(eth_dev);
 		bond_ethdev_close(eth_dev);
 	}
-	if (internals->kvlist != NULL)
-		rte_kvargs_free(internals->kvlist);
 	rte_eth_dev_release_port(eth_dev);
 
 	return ret;
Signature · 1 line
2.27.0
#1 lore raw

Hi, dapengx,

	Why not free internals->kvlist at the end of "bond_ethdev_configure" ? 

Does it call some bugs?

Quoted 39 lines · 在 2021/9/15 13:08, [email protected] 写道:

From: Dapeng Yu <[email protected]>

If the bond device was created by vdev mode, the kvlist was not free after the bond device was closed.

This patch fixes it.

Fixes 144dc4739975 ("net/bonding: fix leak on remove")
---
  drivers/net/bonding/rte_eth_bond_pmd.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/bonding/rte_eth_bond_pmd.c +3 -2
index a6755661c4..2e96b850fb 100644
@@ -2163,6 +2163,9 @@ bond_ethdev_close(struct rte_eth_dev *dev)
  	 */
  	rte_mempool_free(internals->mode6.mempool);
 
+	if (internals->kvlist != NULL)
+		rte_kvargs_free(internals->kvlist);
+
  	return 0;
  }
 
@@ -3475,8 +3478,6 @@ bond_remove(struct rte_vdev_device *dev)
  		ret = bond_ethdev_stop(eth_dev);
  		bond_ethdev_close(eth_dev);
  	}
-	if (internals->kvlist != NULL)
-		rte_kvargs_free(internals->kvlist);
  	rte_eth_dev_release_port(eth_dev);
 
  	return ret;
#2 lore raw
Quoted 9 lines

-----Original Message-----
From: Min Hu (Connor) <[email protected]>
Sent: Wednesday, September 15, 2021 2:59 PM
To: Yu, DapengX <[email protected]>; Chas Williams <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] net/bonding: fix memory leak on closing device

Quoted 4 lines

Hi, dapengx,

	Why not free internals->kvlist at the end of

"bond_ethdev_configure" ?
Does it call some bugs?

Just try not to deviate too much from the previous fix: 144dc4739975 ("net/bonding: fix leak on remove") Since it is reasonable.
And releasing port resource in bond_ethdev_close() is in order to
avoid that memory leak detect tool to find memory leak after device is closed.

free internals->kvlist at the end of "bond_ethdev_configure" is also ok.

Quoted 42 lines · 在 2021/9/15 13:08, [email protected] 写道:
Quoted 40 lines

From: Dapeng Yu <[email protected]>

If the bond device was created by vdev mode, the kvlist was not free after the bond device was closed.

This patch fixes it.

Fixes 144dc4739975 ("net/bonding: fix leak on remove")
---
  drivers/net/bonding/rte_eth_bond_pmd.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/bonding/rte_eth_bond_pmd.c +3 -2
index a6755661c4..2e96b850fb 100644
@@ -2163,6 +2163,9 @@ bond_ethdev_close(struct rte_eth_dev *dev)
  	 */
  	rte_mempool_free(internals->mode6.mempool);
 
+	if (internals->kvlist != NULL)
+		rte_kvargs_free(internals->kvlist);
+
  	return 0;
  }
 
@@ -3475,8 +3478,6 @@ bond_remove(struct rte_vdev_device *dev)
  		ret = bond_ethdev_stop(eth_dev);
  		bond_ethdev_close(eth_dev);
  	}
-	if (internals->kvlist != NULL)
-		rte_kvargs_free(internals->kvlist);
  	rte_eth_dev_release_port(eth_dev);
 
  	return ret;
#3 lore raw
Quoted 65 lines · DapengX
Quoted 9 lines

-----Original Message-----
From: Min Hu (Connor) <[email protected]>
Sent: Wednesday, September 15, 2021 2:59 PM
To: Yu, DapengX <[email protected]>; Chas Williams <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] net/bonding: fix memory leak on closing device

Quoted 4 lines

Hi, dapengx,

	Why not free internals->kvlist at the end of

"bond_ethdev_configure" ?
Does it call some bugs?

Just try not to deviate too much from the previous fix: 144dc4739975 ("net/bonding: fix leak on remove") Since it is reasonable.
And releasing port resource in bond_ethdev_close() is in order to
avoid that memory leak detect tool to find memory leak after device is closed.

free internals->kvlist at the end of "bond_ethdev_configure" is also ok.

Quoted 40 lines · 在 2021/9/15 13:08, [email protected] 写道:
Quoted 38 lines

From: Dapeng Yu <[email protected]>

If the bond device was created by vdev mode, the kvlist was not free after the bond device was closed.

This patch fixes it.

Fixes 144dc4739975 ("net/bonding: fix leak on remove")
---
   drivers/net/bonding/rte_eth_bond_pmd.c | 5 +++--
   1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/bonding/rte_eth_bond_pmd.c +3 -2
index a6755661c4..2e96b850fb 100644
@@ -2163,6 +2163,9 @@ bond_ethdev_close(struct rte_eth_dev *dev)
   	 */
   	rte_mempool_free(internals->mode6.mempool);
 
+	if (internals->kvlist != NULL)
+		rte_kvargs_free(internals->kvlist);
+
   	return 0;
   }
 
@@ -3475,8 +3478,6 @@ bond_remove(struct rte_vdev_device *dev)
   		ret = bond_ethdev_stop(eth_dev);
   		bond_ethdev_close(eth_dev);
   	}
-	if (internals->kvlist != NULL)
-		rte_kvargs_free(internals->kvlist);
   	rte_eth_dev_release_port(eth_dev);
 
Quoted 2 lines

drivers/net/bonding/rte_eth_bond_pmd.c bond_remove(struct rte_vdev_device *dev) · line 3483

Quoted 2 lines
drivers/net/bonding/rte_eth_bond_pmd.c +0 -0
   	return ret;

.

Applied
#4 lore raw

On 9/15/2021 9:16 AM, Min Hu (Connor) wrote:

<...>

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · 在 2021/9/15 13:08, [email protected] 写道:
Quoted 5 lines

From: Dapeng Yu <[email protected]>

If the bond device was created by vdev mode, the kvlist was not free after the bond device was closed.

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

This patch fixes it.

Fixes 144dc4739975 ("net/bonding: fix leak on remove")

Applied to dpdk-next-net/main, thanks.