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

luca.boccassi at gmail.com luca.boccassi at gmail.com
Tue Nov 12 23:07:20 CET 2024


Hi,

FYI, your patch has been queued to stable release 22.11.7

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/14/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/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/80a5d7368ba6b3ad236a507b7f975693fe722ecd

Thanks.

Luca Boccassi

---
>From 80a5d7368ba6b3ad236a507b7f975693fe722ecd 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 b88ae631d9..183b5e6a84 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -1533,9 +1533,11 @@ err_secondary:
 	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 bcaf518227..1078d6497d 100644
--- a/drivers/net/mlx5/mlx5_flow_meter.c
+++ b/drivers/net/mlx5/mlx5_flow_meter.c
@@ -100,8 +100,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 f401264b61..d35b949b34 100644
--- a/drivers/net/mlx5/windows/mlx5_os.c
+++ b/drivers/net/mlx5/windows/mlx5_os.c
@@ -474,9 +474,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.45.2

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2024-11-12 22:06:59.016828692 +0000
+++ 0010-net-mlx5-fix-memory-leak-in-metering.patch	2024-11-12 22:06:58.643306826 +0000
@@ -1 +1 @@
-From 4dd46d38820e0bf5e74f99b84f4b098d1b7220dd Mon Sep 17 00:00:00 2001
+From 80a5d7368ba6b3ad236a507b7f975693fe722ecd 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 b88ae631d9..183b5e6a84 100644
@@ -25 +26 @@
-@@ -1612,9 +1612,11 @@ err_secondary:
+@@ -1533,9 +1533,11 @@ err_secondary:
@@ -41 +42 @@
-index 19d8607070..98a61cbdd4 100644
+index bcaf518227..1078d6497d 100644
@@ -44 +45 @@
-@@ -378,8 +378,8 @@ mlx5_flow_meter_profile_find(struct mlx5_priv *priv, uint32_t meter_profile_id)
+@@ -100,8 +100,8 @@ mlx5_flow_meter_profile_find(struct mlx5_priv *priv, uint32_t meter_profile_id)
@@ -56 +57 @@
-index 80f1679388..268598f209 100644
+index f401264b61..d35b949b34 100644
@@ -59 +60 @@
-@@ -521,9 +521,11 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
+@@ -474,9 +474,11 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,


More information about the stable mailing list