DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Maayan Kashani <mkashani@nvidia.com>
To: <dev@dpdk.org>
Cc: <viacheslavo@nvidia.com>, <bingz@nvidia.com>, <orika@nvidia.com>,
	<suanmingm@nvidia.com>, <matan@nvidia.com>,
	Maayan Kashani <mkashani@nvidia.com>, <stable@dpdk.org>,
	Dariusz Sosnowski <dsosnowski@nvidia.com>
Subject: [PATCH 1/2] net/mlx5: embed HWS counter pool name in the pool
Date: Mon, 9 Nov 2026 14:57:39 +0200	[thread overview]
Message-ID: <20261109125740.4034743-1-mkashani@nvidia.com> (raw)

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")
Cc: stable@dpdk.org

Signed-off-by: Maayan Kashani <mkashani@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@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 d0c4ead71b7..d6f713fd9bd 100644
--- a/drivers/net/mlx5/mlx5_hws_cnt.c
+++ b/drivers/net/mlx5/mlx5_hws_cnt.c
@@ -730,18 +730,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) {
@@ -814,7 +807,6 @@ mlx5_hws_cnt_pool_create(struct rte_eth_dev *dev,
 	MLX5_ASSERT(ret);
 	mlx5_hws_cnt_pool_destroy(priv->sh, cpool);
 	priv->hws_cpool = NULL;
-	mlx5_free(mp_name);
 	return ret;
 }
 
@@ -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);
 	}
-	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 63a14f4f7a0..5a55820abec 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"
@@ -87,7 +88,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.25.1


             reply	other threads:[~2026-11-09 12:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 12:57 Maayan Kashani [this message]
2026-11-09 12:57 ` [PATCH 2/2] net/mlx5: report HWS counter pool allocation failure Maayan Kashani
2026-11-11 13:11   ` Raslan Darawsheh
2026-11-11 13:11 ` [PATCH 1/2] net/mlx5: embed HWS counter pool name in the pool Raslan Darawsheh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261109125740.4034743-1-mkashani@nvidia.com \
    --to=mkashani@nvidia.com \
    --cc=bingz@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=dsosnowski@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=suanmingm@nvidia.com \
    --cc=viacheslavo@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox