DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>,
	stable@dpdk.org, Dariusz Sosnowski <dsosnowski@nvidia.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Bing Zhao <bingz@nvidia.com>, Ori Kam <orika@nvidia.com>,
	Suanming Mou <suanmingm@nvidia.com>,
	Matan Azrad <matan@nvidia.com>,
	Michael Baum <michaelba@nvidia.com>,
	Gregory Etelson <getelson@nvidia.com>
Subject: [PATCH 12/17] net/mlx5: replace strncpy with strlcpy
Date: Tue, 23 Jun 2026 17:51:42 +0100	[thread overview]
Message-ID: <20260623165150.765443-13-bruce.richardson@intel.com> (raw)
In-Reply-To: <20260623165150.765443-1-bruce.richardson@intel.com>

Replace strncpy() with safer strlcpy() which always null-terminates.

Fixes: ca1418ce3910 ("common/mlx5: share device context object")
Fixes: 9e58a50c059f ("net/mlx5: fix interface name parameter definition")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/mlx5/mlx5.c                   | 8 ++++----
 drivers/net/mlx5/windows/mlx5_ethdev_os.c | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 61c26d1206..24fda18710 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -1916,10 +1916,10 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
 	sh->txpp.skew = sh->config.tx_skew;
 	sh->refcnt = 1;
 	sh->max_port = spawn->max_port;
-	strncpy(sh->ibdev_name, mlx5_os_get_ctx_device_name(sh->cdev->ctx),
-		sizeof(sh->ibdev_name) - 1);
-	strncpy(sh->ibdev_path, mlx5_os_get_ctx_device_path(sh->cdev->ctx),
-		sizeof(sh->ibdev_path) - 1);
+	strlcpy(sh->ibdev_name, mlx5_os_get_ctx_device_name(sh->cdev->ctx),
+		sizeof(sh->ibdev_name));
+	strlcpy(sh->ibdev_path, mlx5_os_get_ctx_device_path(sh->cdev->ctx),
+		sizeof(sh->ibdev_path));
 	sh->phdev = mlx5_get_physical_device(sh->cdev);
 	if (!sh->phdev)
 		goto error;
diff --git a/drivers/net/mlx5/windows/mlx5_ethdev_os.c b/drivers/net/mlx5/windows/mlx5_ethdev_os.c
index e24ff367af..ecb8914a65 100644
--- a/drivers/net/mlx5/windows/mlx5_ethdev_os.c
+++ b/drivers/net/mlx5/windows/mlx5_ethdev_os.c
@@ -67,7 +67,7 @@ mlx5_get_ifname(const struct rte_eth_dev *dev, char ifname[MLX5_NAMESIZE])
 	}
 	priv = dev->data->dev_private;
 	context_obj = (mlx5_context_st *)priv->sh->cdev->ctx;
-	strncpy(ifname, context_obj->mlx5_dev.name, MLX5_NAMESIZE);
+	strlcpy(ifname, context_obj->mlx5_dev.name, MLX5_NAMESIZE);
 	return 0;
 }
 
-- 
2.53.0


  parent reply	other threads:[~2026-06-23 16:53 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-23 16:51 [PATCH 00/17] drivers: replace strncpy with strlcpy Bruce Richardson
2026-06-23 16:51 ` [PATCH 01/17] common/cnxk: " Bruce Richardson
2026-06-23 16:51 ` [PATCH 02/17] common/mlx5: " Bruce Richardson
2026-06-23 16:51 ` [PATCH 03/17] crypto/mvsam: " Bruce Richardson
2026-06-23 16:51 ` [PATCH 04/17] crypto/scheduler: " Bruce Richardson
2026-06-23 16:59   ` Bruce Richardson
2026-06-23 16:51 ` [PATCH 05/17] event/cnxk: " Bruce Richardson
2026-06-23 16:51 ` [PATCH 06/17] net/ark: " Bruce Richardson
2026-06-23 16:51 ` [PATCH 07/17] net/bnx2x: " Bruce Richardson
2026-06-23 16:51 ` [PATCH 08/17] net/cnxk: " Bruce Richardson
2026-06-23 16:51 ` [PATCH 09/17] net/dpaa: " Bruce Richardson
2026-06-23 16:51 ` [PATCH 10/17] net/ionic: " Bruce Richardson
2026-06-23 16:51 ` [PATCH 11/17] net/mlx4: " Bruce Richardson
2026-06-23 16:51 ` Bruce Richardson [this message]
2026-06-23 16:51 ` [PATCH 13/17] net/nfp: " Bruce Richardson
2026-06-23 16:51 ` [PATCH 14/17] net/qede: " Bruce Richardson
2026-06-23 17:02   ` Bruce Richardson
2026-06-23 16:51 ` [PATCH 15/17] net/softnic: " Bruce Richardson
2026-06-23 16:51 ` [PATCH 16/17] net/vhost: " Bruce Richardson
2026-06-23 16:51 ` [PATCH 17/17] net/virtio: " Bruce Richardson
2026-06-23 17:33 ` [PATCH 00/17] drivers: " Stephen Hemminger

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=20260623165150.765443-13-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=bingz@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=dsosnowski@nvidia.com \
    --cc=getelson@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=michaelba@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