[PATCH_v4,2/3] regex/mlx5: fix leak in PCI remove function

Message ID 20210712070644.2848418-3-michaelba@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series regex/mlx5: some independent fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Michael Baum July 12, 2021, 7:06 a.m. UTC
  In the PCI removal function, PMD releases all driver resources allocated
in the probe function.

The MR btree memory is allocated in the probe function, but it is not
freed in remove function what caused a memory leak.

Release it.

Fixes: cda883bbb655 ("regex/mlx5: add dynamic memory registration to datapath")
Cc: stable@dpdk.org

Signed-off-by: Michael Baum <michaelba@nvidia.com>
---
 drivers/regex/mlx5/mlx5_regex.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Ori Kam July 21, 2021, 6:21 a.m. UTC | #1
Hi Michael,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Michael Baum
> Sent: Monday, July 12, 2021 10:07 AM
> 
> In the PCI removal function, PMD releases all driver resources allocated in
> the probe function.
> 
> The MR btree memory is allocated in the probe function, but it is not freed in
> remove function what caused a memory leak.
> 
> Release it.
> 
> Fixes: cda883bbb655 ("regex/mlx5: add dynamic memory registration to
> datapath")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Michael Baum <michaelba@nvidia.com>
> ---
>  drivers/regex/mlx5/mlx5_regex.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/regex/mlx5/mlx5_regex.c
> b/drivers/regex/mlx5/mlx5_regex.c index 0f12d94d7e..f64dc2824c 100644
> --- a/drivers/regex/mlx5/mlx5_regex.c
> +++ b/drivers/regex/mlx5/mlx5_regex.c
> @@ -280,6 +280,8 @@ mlx5_regex_pci_remove(struct rte_pci_device
> *pci_dev)
>  		if (TAILQ_EMPTY(&mlx5_mem_event_list))
> 
> 	rte_mem_event_callback_unregister("MLX5_MEM_EVENT_CB",
>  							  NULL);
> +		if (priv->mr_scache.cache.table)
> +			mlx5_mr_release_cache(&priv->mr_scache);
>  		if (priv->pd)
>  			mlx5_glue->dealloc_pd(priv->pd);
>  		if (priv->uar)
> --
> 2.25.1

Acked-by: Ori Kam <orika@nvidia.com>
Thanks,
Ori
  

Patch

diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c
index 0f12d94d7e..f64dc2824c 100644
--- a/drivers/regex/mlx5/mlx5_regex.c
+++ b/drivers/regex/mlx5/mlx5_regex.c
@@ -280,6 +280,8 @@  mlx5_regex_pci_remove(struct rte_pci_device *pci_dev)
 		if (TAILQ_EMPTY(&mlx5_mem_event_list))
 			rte_mem_event_callback_unregister("MLX5_MEM_EVENT_CB",
 							  NULL);
+		if (priv->mr_scache.cache.table)
+			mlx5_mr_release_cache(&priv->mr_scache);
 		if (priv->pd)
 			mlx5_glue->dealloc_pd(priv->pd);
 		if (priv->uar)