patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH v3] net/mlx5: fix potential memory leak in meter
@ 2024-10-23  6:22 Shun Hao
  2024-10-28 13:13 ` Raslan Darawsheh
  0 siblings, 1 reply; 2+ messages in thread
From: Shun Hao @ 2024-10-23  6:22 UTC (permalink / raw)
  To: viacheslavo, matan, orika, Dariusz Sosnowski, Bing Zhao, Suanming Mou
  Cc: dev, rasland, stable

When meter not enabled, avoid allocate memory for meter profile table,
which will not be freed in close process when meter not enabled

Fixes: a295c69a8b24 ("net/mlx5: optimize meter profile lookup")
Cc: stable@dpdk.org

Signed-off-by: Shun Hao <shunh@nvidia.com>
Acked-by: Bing Zhao <bingz@nvidia.com>
---
 drivers/net/mlx5/linux/mlx5_os.c   | 8 +++++---
 drivers/net/mlx5/mlx5_flow_meter.c | 4 ++--
 drivers/net/mlx5/windows/mlx5_os.c | 8 +++++---
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 0a8de88759..3881daf5cc 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -1612,9 +1612,11 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 	priv->ctrl_flows = 0;
 	rte_spinlock_init(&priv->flow_list_lock);
 	TAILQ_INIT(&priv->flow_meters);
-	priv->mtr_profile_tbl = mlx5_l3t_create(MLX5_L3T_TYPE_PTR);
-	if (!priv->mtr_profile_tbl)
-		goto error;
+	if (priv->mtr_en) {
+		priv->mtr_profile_tbl = mlx5_l3t_create(MLX5_L3T_TYPE_PTR);
+		if (!priv->mtr_profile_tbl)
+			goto error;
+	}
 	/* Bring Ethernet device up. */
 	DRV_LOG(DEBUG, "port %u forcing Ethernet interface up",
 		eth_dev->data->port_id);
diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c
index 19d8607070..98a61cbdd4 100644
--- a/drivers/net/mlx5/mlx5_flow_meter.c
+++ b/drivers/net/mlx5/mlx5_flow_meter.c
@@ -378,8 +378,8 @@ mlx5_flow_meter_profile_find(struct mlx5_priv *priv, uint32_t meter_profile_id)
 
 	if (priv->mtr_profile_arr)
 		return &priv->mtr_profile_arr[meter_profile_id];
-	if (mlx5_l3t_get_entry(priv->mtr_profile_tbl,
-			       meter_profile_id, &data) || !data.ptr)
+	if (!priv->mtr_profile_tbl ||
+	    mlx5_l3t_get_entry(priv->mtr_profile_tbl, meter_profile_id, &data) || !data.ptr)
 		return NULL;
 	fmp = data.ptr;
 	/* Remove reference taken by the mlx5_l3t_get_entry. */
diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c
index 0ebd233595..61ad06a373 100644
--- a/drivers/net/mlx5/windows/mlx5_os.c
+++ b/drivers/net/mlx5/windows/mlx5_os.c
@@ -521,9 +521,11 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 	claim_zero(mlx5_mac_addr_add(eth_dev, &mac, 0, 0));
 	priv->ctrl_flows = 0;
 	TAILQ_INIT(&priv->flow_meters);
-	priv->mtr_profile_tbl = mlx5_l3t_create(MLX5_L3T_TYPE_PTR);
-	if (!priv->mtr_profile_tbl)
-		goto error;
+	if (priv->mtr_en) {
+		priv->mtr_profile_tbl = mlx5_l3t_create(MLX5_L3T_TYPE_PTR);
+		if (!priv->mtr_profile_tbl)
+			goto error;
+	}
 	/* Bring Ethernet device up. */
 	DRV_LOG(DEBUG, "port %u forcing Ethernet interface up.",
 		eth_dev->data->port_id);
-- 
2.20.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] net/mlx5: fix potential memory leak in meter
  2024-10-23  6:22 [PATCH v3] net/mlx5: fix potential memory leak in meter Shun Hao
@ 2024-10-28 13:13 ` Raslan Darawsheh
  0 siblings, 0 replies; 2+ messages in thread
From: Raslan Darawsheh @ 2024-10-28 13:13 UTC (permalink / raw)
  To: Shun Hao, Slava Ovsiienko, Matan Azrad, Ori Kam,
	Dariusz Sosnowski, Bing Zhao, Suanming Mou
  Cc: dev, stable

Hi,
From: Shun Hao <shunh@nvidia.com>
Sent: Wednesday, October 23, 2024 9:22 AM
To: Slava Ovsiienko; Matan Azrad; Ori Kam; Dariusz Sosnowski; Bing Zhao; Suanming Mou
Cc: dev@dpdk.org; Raslan Darawsheh; stable@dpdk.org
Subject: [PATCH v3] net/mlx5: fix potential memory leak in meter

When meter not enabled, avoid allocate memory for meter profile table,
which will not be freed in close process when meter not enabled

Fixes: a295c69a8b24 ("net/mlx5: optimize meter profile lookup")
Cc: stable@dpdk.org

Signed-off-by: Shun Hao <shunh@nvidia.com>
Acked-by: Bing Zhao <bingz@nvidia.com>

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-28 13:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-23  6:22 [PATCH v3] net/mlx5: fix potential memory leak in meter Shun Hao
2024-10-28 13:13 ` Raslan Darawsheh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).