[v2] net/softnic: fix memory leak of meter policy

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

Checks

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

Commit Message

Yu, DapengX Oct. 14, 2021, 2:12 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>
---
V2:
* Rebase on top of main branch
---
 drivers/net/softnic/rte_eth_softnic_meter.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
  

Comments

Jasvinder Singh Oct. 19, 2021, 2:01 p.m. UTC | #1
> -----Original Message-----
> From: Yu, DapengX <dapengx.yu@intel.com>
> Sent: Thursday, October 14, 2021 3:12 AM
> To: Singh, Jasvinder <jasvinder.singh@intel.com>; Dumitrescu, Cristian
> <cristian.dumitrescu@intel.com>
> Cc: dev@dpdk.org; Yu, DapengX <dapengx.yu@intel.com>; stable@dpdk.org
> Subject: [PATCH v2] net/softnic: fix memory leak of meter policy
> 
> 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>
> ---
> V2:
> * Rebase on top of main branch
> ---
>  drivers/net/softnic/rte_eth_softnic_meter.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> 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 *
> --
> 2.27.0

Acked-by: Jasvinder Singh <jasvinder.singh@intel.com>
  
Ferruh Yigit Oct. 19, 2021, 8:46 p.m. UTC | #2
On 10/19/2021 3:01 PM, Singh, Jasvinder wrote:
> 
> 
>> -----Original Message-----
>> From: Yu, DapengX <dapengx.yu@intel.com>
>> Sent: Thursday, October 14, 2021 3:12 AM
>> To: Singh, Jasvinder <jasvinder.singh@intel.com>; Dumitrescu, Cristian
>> <cristian.dumitrescu@intel.com>
>> Cc: dev@dpdk.org; Yu, DapengX <dapengx.yu@intel.com>; stable@dpdk.org
>> Subject: [PATCH v2] net/softnic: fix memory leak of meter policy
>>
>> 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>
> 
> Acked-by: Jasvinder Singh <jasvinder.singh@intel.com>
> 

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

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 *