net/softnic: fix memory leak of meter policy

Message ID 20210930083444.636152-1-dapengx.yu@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series net/softnic: fix memory leak of meter policy |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing fail Testing issues
ci/iol-x86_64-compile-testing fail Testing issues
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Yu, DapengX Sept. 30, 2021, 8:34 a.m. UTC
  From: Dapeng Yu <dapengx.yu@intel.com>

After the meter policies are created, they are not freed on device
close.

This patch fixes it.

Fixes: 5f0d54f372f0 ("ethdev: add pre-defined meter policy API")
Cc: stable@dpdk.org

Signed-off-by: Dapeng Yu <dapengx.yu@intel.com>
---
 drivers/net/softnic/rte_eth_softnic_meter.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
  

Patch

diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c b/drivers/net/softnic/rte_eth_softnic_meter.c
index 5831892a39..6b02f43e31 100644
--- a/drivers/net/softnic/rte_eth_softnic_meter.c
+++ b/drivers/net/softnic/rte_eth_softnic_meter.c
@@ -52,6 +52,18 @@  softnic_mtr_free(struct pmd_internals *p)
 		TAILQ_REMOVE(&p->mtr.meter_profiles, mp, node);
 		free(mp);
 	}
+
+	/* Remove meter policies */
+	for ( ; ; ) {
+		struct softnic_mtr_meter_policy *mp;
+
+		mp = TAILQ_FIRST(&p->mtr.meter_policies);
+		if (mp == NULL)
+			break;
+
+		TAILQ_REMOVE(&p->mtr.meter_policies, mp, node);
+		free(mp);
+	}
 }
 
 struct softnic_mtr_meter_profile *