From: Dapeng Yu Date: Thu, 14 Oct 2021 02:12:07 +0000 (+0800) Subject: net/softnic: fix memory leak of meter policy X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=287ca31bea159a35ee755e1e75900203945dc536;p=dpdk.git net/softnic: fix memory leak of meter policy 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 Acked-by: Jasvinder Singh --- 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 *