patch 'net/mlx5: fix double free of HWS counter pool name' has been queued to stable release 24.11.9

luca.boccassi at gmail.com luca.boccassi at gmail.com
Mon Nov 16 23:52:13 CET 2026


Hi,

FYI, your patch has been queued to stable release 24.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 11/18/26. 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/bc476990ddebc577a558cd0c6e99451dc2c2e7a6

Thanks.

Luca Boccassi

---
>From bc476990ddebc577a558cd0c6e99451dc2c2e7a6 Mon Sep 17 00:00:00 2001
From: Maayan Kashani <mkashani at nvidia.com>
Date: Mon, 9 Nov 2026 14:57:39 +0200
Subject: [PATCH] net/mlx5: fix double free of HWS counter pool name

[ upstream commit 682a585ac0c5ee20c487a7cd644676e10565b609 ]

The pool name is a small fixed string, but it was allocated separately
and the pointer was stored in the pool config. Destroy always freed
that pointer. The create error path freed it again, which logged
"Invalid memory".

Keep the name in the pool config. The string is copied with the config,
so create and destroy no longer allocate or free it.

Fixes: 9e34fcc81c00 ("net/mlx5: fix leak in HWS flow counter action")

Signed-off-by: Maayan Kashani <mkashani at nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski at nvidia.com>
---
 drivers/net/mlx5/mlx5_hws_cnt.c | 13 ++-----------
 drivers/net/mlx5/mlx5_hws_cnt.h |  3 ++-
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_hws_cnt.c b/drivers/net/mlx5/mlx5_hws_cnt.c
index 3a93434ecd..c55497e3b0 100644
--- a/drivers/net/mlx5/mlx5_hws_cnt.c
+++ b/drivers/net/mlx5/mlx5_hws_cnt.c
@@ -697,18 +697,11 @@ mlx5_hws_cnt_pool_create(struct rte_eth_dev *dev,
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_hws_cache_param cparam = {0};
 	struct mlx5_hws_cnt_pool_cfg pcfg = {0};
-	char *mp_name;
 	int ret = 0;
 	size_t sz;
 
-	mp_name = mlx5_malloc(MLX5_MEM_ZERO, RTE_MEMZONE_NAMESIZE, 0, SOCKET_ID_ANY);
-	if (mp_name == NULL) {
-		ret = rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
-					 "failed to allocate counter pool name prefix");
-		goto error;
-	}
-	snprintf(mp_name, RTE_MEMZONE_NAMESIZE, "MLX5_HWS_CNT_P_%x", dev->data->port_id);
-	pcfg.name = mp_name;
+	snprintf(pcfg.name, sizeof(pcfg.name), "MLX5_HWS_CNT_P_%x",
+		 dev->data->port_id);
 	pcfg.request_num = nb_counters;
 	pcfg.alloc_factor = HWS_CNT_ALLOC_FACTOR_DEFAULT;
 	if (chost) {
@@ -779,7 +772,6 @@ error:
 	MLX5_ASSERT(ret);
 	mlx5_hws_cnt_pool_destroy(priv->sh, cpool);
 	priv->hws_cpool = NULL;
-	mlx5_free(mp_name);
 	return ret;
 }
 
@@ -807,7 +799,6 @@ mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,
 		mlx5_hws_cnt_pool_dcs_free(sh, cpool);
 		mlx5_hws_cnt_raw_data_free(sh, cpool->raw_mng);
 	}
-	mlx5_free((void *)cpool->cfg.name);
 	mlx5_hws_cnt_pool_deinit(cpool);
 }
 
diff --git a/drivers/net/mlx5/mlx5_hws_cnt.h b/drivers/net/mlx5/mlx5_hws_cnt.h
index e15cd49b91..12c1b1baae 100644
--- a/drivers/net/mlx5/mlx5_hws_cnt.h
+++ b/drivers/net/mlx5/mlx5_hws_cnt.h
@@ -5,6 +5,7 @@
 #ifndef _MLX5_HWS_CNT_H_
 #define _MLX5_HWS_CNT_H_
 
+#include <rte_memzone.h>
 #include <rte_ring.h>
 #include "mlx5_utils.h"
 #include "mlx5_flow.h"
@@ -86,7 +87,7 @@ struct mlx5_hws_cache_param {
 };
 
 struct mlx5_hws_cnt_pool_cfg {
-	char *name;
+	char name[RTE_MEMZONE_NAMESIZE];
 	uint32_t request_num;
 	uint32_t alloc_factor;
 	struct mlx5_hws_cnt_pool *host_cpool;
-- 
2.47.3

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2026-11-16 22:52:18.844321352 +0000
+++ 0059-net-mlx5-fix-double-free-of-HWS-counter-pool-name.patch	2026-11-16 22:52:16.516234226 +0000
@@ -1 +1 @@
-From 682a585ac0c5ee20c487a7cd644676e10565b609 Mon Sep 17 00:00:00 2001
+From bc476990ddebc577a558cd0c6e99451dc2c2e7a6 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 682a585ac0c5ee20c487a7cd644676e10565b609 ]
+
@@ -15 +16,0 @@
-Cc: stable at dpdk.org
@@ -25 +26 @@
-index d0c4ead71b..d6f713fd9b 100644
+index 3a93434ecd..c55497e3b0 100644
@@ -28 +29 @@
-@@ -730,18 +730,11 @@ mlx5_hws_cnt_pool_create(struct rte_eth_dev *dev,
+@@ -697,18 +697,11 @@ mlx5_hws_cnt_pool_create(struct rte_eth_dev *dev,
@@ -49 +50 @@
-@@ -814,7 +807,6 @@ error:
+@@ -779,7 +772,6 @@ error:
@@ -57,3 +58,3 @@
-@@ -842,7 +834,6 @@ mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,
- 		mlx5_hws_cnt_pool_dcs_free(cpool);
- 		mlx5_hws_cnt_raw_data_free(cpool->raw_mng);
+@@ -807,7 +799,6 @@ mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,
+ 		mlx5_hws_cnt_pool_dcs_free(sh, cpool);
+ 		mlx5_hws_cnt_raw_data_free(sh, cpool->raw_mng);
@@ -66 +67 @@
-index 63a14f4f7a..5a55820abe 100644
+index e15cd49b91..12c1b1baae 100644
@@ -77 +78 @@
-@@ -87,7 +88,7 @@ struct mlx5_hws_cache_param {
+@@ -86,7 +87,7 @@ struct mlx5_hws_cache_param {


More information about the stable mailing list