patch 'net/mlx5: fix memory leak in metering' has been queued to stable release 21.11.9

Kevin Traynor ktraynor at redhat.com
Wed Nov 27 18:18:23 CET 2024


Hi,

FYI, your patch has been queued to stable release 21.11.9

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 12/02/24. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/65c3055305aa57088ed84e05aa79edcf8dc6714a

Thanks.

Kevin

---
>From 65c3055305aa57088ed84e05aa79edcf8dc6714a Mon Sep 17 00:00:00 2001
From: Shun Hao <shunh at nvidia.com>
Date: Wed, 23 Oct 2024 09:22:15 +0300
Subject: [PATCH] net/mlx5: fix memory leak in metering

[ upstream commit 4dd46d38820e0bf5e74f99b84f4b098d1b7220dd ]

Avoid allocating memory for meter profile table when meter is not
enabled. This memory was not being freed in the close process when
meter was disabled, potentially causing a leak.

Fixes: a295c69a8b24 ("net/mlx5: optimize meter profile lookup")

Signed-off-by: Shun Hao <shunh at nvidia.com>
Acked-by: Bing Zhao <bingz at 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 841512faa3..f5a61f38e8 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -1663,7 +1663,9 @@ err_secondary:
 	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",
diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c
index fd3f993892..3623147bcd 100644
--- a/drivers/net/mlx5/mlx5_flow_meter.c
+++ b/drivers/net/mlx5/mlx5_flow_meter.c
@@ -99,6 +99,6 @@ mlx5_flow_meter_profile_find(struct mlx5_priv *priv, uint32_t meter_profile_id)
 	int32_t ret;
 
-	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;
diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c
index ba99901c5c..2f11bd1d23 100644
--- a/drivers/net/mlx5/windows/mlx5_os.c
+++ b/drivers/net/mlx5/windows/mlx5_os.c
@@ -584,7 +584,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 	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.",
-- 
2.47.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2024-11-27 17:17:40.648771905 +0000
+++ 0076-net-mlx5-fix-memory-leak-in-metering.patch	2024-11-27 17:17:38.277269643 +0000
@@ -1 +1 @@
-From 4dd46d38820e0bf5e74f99b84f4b098d1b7220dd Mon Sep 17 00:00:00 2001
+From 65c3055305aa57088ed84e05aa79edcf8dc6714a Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 4dd46d38820e0bf5e74f99b84f4b098d1b7220dd ]
+
@@ -11 +12,0 @@
-Cc: stable at dpdk.org
@@ -22 +23 @@
-index 7d0d4bf23b..69a80b9ddc 100644
+index 841512faa3..f5a61f38e8 100644
@@ -25 +26 @@
-@@ -1613,7 +1613,9 @@ err_secondary:
+@@ -1663,7 +1663,9 @@ err_secondary:
@@ -39 +40 @@
-index 19d8607070..98a61cbdd4 100644
+index fd3f993892..3623147bcd 100644
@@ -42,3 +43,3 @@
-@@ -379,6 +379,6 @@ 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];
+@@ -99,6 +99,6 @@ mlx5_flow_meter_profile_find(struct mlx5_priv *priv, uint32_t meter_profile_id)
+ 	int32_t ret;
+ 
@@ -52 +53 @@
-index 80f1679388..268598f209 100644
+index ba99901c5c..2f11bd1d23 100644
@@ -55 +56 @@
-@@ -522,7 +522,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
+@@ -584,7 +584,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,



More information about the stable mailing list