DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 06/12] bus/vmbus: fix interrupt leak in cleanup
From: David Marchand @ 2026-06-24 10:43 UTC (permalink / raw)
  To: dev
  Cc: thomas, stephen, bruce.richardson, fengchengwen, longli,
	hemant.agrawal, stable, Wei Hu
In-Reply-To: <20260624104324.3576408-1-david.marchand@redhat.com>

When calling this bus cleanup, interrupt handle was not released.

Fixes: 65780eada9d9 ("bus/vmbus: support cleanup")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
Reviewed-by: Long Li <longli@microsoft.com>
---
 drivers/bus/vmbus/vmbus_common.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c
index 01573927ce..74c1ddff69 100644
--- a/drivers/bus/vmbus/vmbus_common.c
+++ b/drivers/bus/vmbus/vmbus_common.c
@@ -150,6 +150,7 @@ rte_vmbus_cleanup(void)
 			error = -1;
 
 		rte_vmbus_unmap_device(dev);
+		rte_intr_instance_free(dev->intr_handle);
 
 		dev->device.driver = NULL;
 		rte_bus_remove_device(&rte_vmbus_bus, &dev->device);
-- 
2.54.0


^ permalink raw reply related

* [PATCH v4 05/12] bus/pci: fix mapping leak in bus cleanup
From: David Marchand @ 2026-06-24 10:43 UTC (permalink / raw)
  To: dev
  Cc: thomas, stephen, bruce.richardson, fengchengwen, longli,
	hemant.agrawal, stable, Chenbo Xia, Nipun Gupta,
	Morten Brørup, Kevin Laatz
In-Reply-To: <20260624104324.3576408-1-david.marchand@redhat.com>

When calling this bus cleanup, PCI resources were not unmapped.

Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/bus/pci/pci_common.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index fd18b8772b..791e9a7b49 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -344,6 +344,10 @@ pci_cleanup(void)
 			rte_errno = errno;
 			error = -1;
 		}
+
+		if (drv->drv_flags & RTE_PCI_DRV_NEED_MAPPING)
+			rte_pci_unmap_device(dev);
+
 		dev->device.driver = NULL;
 
 free:
-- 
2.54.0


^ permalink raw reply related

* [PATCH v4 04/12] vdpa/nfp: fix double PCI unmap on unplug
From: David Marchand @ 2026-06-24 10:43 UTC (permalink / raw)
  To: dev
  Cc: thomas, stephen, bruce.richardson, fengchengwen, longli,
	hemant.agrawal, stable, Chaoyong He, Peng Zhang, Long Wu,
	Shujing Dong
In-Reply-To: <20260624104324.3576408-1-david.marchand@redhat.com>

This driver uses its own VFIO container and handles mapping/unmapping
itself. It should not use RTE_PCI_DRV_NEED_MAPPING flag, which causes
the PCI bus to also attempt unmapping, resulting in double free.

Fixes: 7b2a1228c59d ("vdpa/nfp: add remap PCI memory")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/vdpa/nfp/nfp_vdpa.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index f4fd5c92ec..4c0ab3ff30 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -119,8 +119,6 @@ nfp_vdpa_vfio_setup(struct nfp_vdpa_dev *device)
 	char dev_name[RTE_DEV_NAME_MAX_LEN] = {0};
 	struct rte_pci_device *pci_dev = device->pci_dev;
 
-	rte_pci_unmap_device(pci_dev);
-
 	rte_pci_device_name(&pci_dev->addr, dev_name, RTE_DEV_NAME_MAX_LEN);
 	ret = rte_vfio_get_group_num(rte_pci_get_sysfs_path(), dev_name,
 			&device->iommu_group);
@@ -1301,7 +1299,7 @@ static struct nfp_class_driver nfp_vdpa = {
 	.drv_class = NFP_CLASS_VDPA,
 	.name = RTE_STR(NFP_VDPA_DRIVER_NAME),
 	.id_table = pci_id_nfp_vdpa_map,
-	.drv_flags =  RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+	.drv_flags = RTE_PCI_DRV_INTR_LSC,
 	.probe = nfp_vdpa_pci_probe,
 	.remove = nfp_vdpa_pci_remove,
 };
-- 
2.54.0


^ permalink raw reply related

* [PATCH v4 03/12] bus/vdev: remove driver setting in probe
From: David Marchand @ 2026-06-24 10:43 UTC (permalink / raw)
  To: dev; +Cc: thomas, stephen, bruce.richardson, fengchengwen, longli,
	hemant.agrawal
In-Reply-To: <20260624104324.3576408-1-david.marchand@redhat.com>

Setting the device driver field is not the responsibility of the
probe_device callback anymore, but that of EAL (see local_dev_probe).
Yet, because of the VDEV API, rte_vdev_init() must be updated to mark
the device as probed.

Fixes: f282771a04ef ("bus: factorize driver reference")

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
Changes since v1:
- implement the same way as EAL,

---
 drivers/bus/vdev/vdev.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index 3bddf8938c..09221ccdea 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -188,7 +188,6 @@ vdev_probe_device(struct rte_driver *drv, struct rte_device *dev)
 	struct rte_vdev_driver *vdev_drv = RTE_BUS_DRIVER(drv, *vdev_drv);
 	const char *name;
 	enum rte_iova_mode iova_mode;
-	int ret;
 
 	name = rte_vdev_device_name(vdev_dev);
 	VDEV_LOG(DEBUG, "Search driver to probe device %s", name);
@@ -200,10 +199,7 @@ vdev_probe_device(struct rte_driver *drv, struct rte_device *dev)
 		return -1;
 	}
 
-	ret = vdev_drv->probe(vdev_dev);
-	if (ret == 0)
-		vdev_dev->device.driver = &vdev_drv->driver;
-	return ret;
+	return vdev_drv->probe(vdev_dev);
 }
 
 /* The caller shall be responsible for thread-safe */
@@ -328,7 +324,10 @@ rte_vdev_init(const char *name, const char *args)
 		} else if (rte_dev_is_probed(&dev->device)) {
 			ret = -EEXIST;
 		} else {
+			dev->device.driver = drv;
 			ret = rte_vdev_bus.probe_device(drv, &dev->device);
+			if (ret != 0)
+				dev->device.driver = NULL;
 		}
 		if (ret < 0) {
 			/* If fails, remove it from vdev list */
-- 
2.54.0


^ permalink raw reply related

* [PATCH v4 02/12] dma/idxd: remove next pointer in bus specific device
From: David Marchand @ 2026-06-24 10:43 UTC (permalink / raw)
  To: dev
  Cc: thomas, stephen, bruce.richardson, fengchengwen, longli,
	hemant.agrawal, Kevin Laatz
In-Reply-To: <20260624104324.3576408-1-david.marchand@redhat.com>

The dma/idxd devices are now stored in a list of generic rte_device
objects.

Fixes: b4f0974a995b ("bus: factorize device list")

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/dma/idxd/idxd_bus.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/dma/idxd/idxd_bus.c b/drivers/dma/idxd/idxd_bus.c
index 4810d52f2a..2ec526ec09 100644
--- a/drivers/dma/idxd/idxd_bus.c
+++ b/drivers/dma/idxd/idxd_bus.c
@@ -34,7 +34,6 @@ struct dsa_wq_addr {
 /** a DSA device instance */
 struct rte_dsa_device {
 	struct rte_device device;           /**< Inherit core device */
-	TAILQ_ENTRY(rte_dsa_device) next;   /**< next dev in list */
 
 	char wq_name[32];                   /**< the workqueue name/number e.g. wq0.1 */
 	struct dsa_wq_addr addr;            /**< Identifies the specific WQ */
-- 
2.54.0


^ permalink raw reply related

* [PATCH v4 01/12] bus: fix reference to plug callback
From: David Marchand @ 2026-06-24 10:43 UTC (permalink / raw)
  To: dev; +Cc: thomas, stephen, bruce.richardson, fengchengwen, longli,
	hemant.agrawal
In-Reply-To: <20260624104324.3576408-1-david.marchand@redhat.com>

Remove now unused typedef, update documentation
and some log following the callback rename.

Fixes: 76622feba9e6 ("bus: refactor device probe")

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
Changes since v1:
- remove missed rte_bus_plug_t typedef,

---
 doc/guides/prog_guide/device_hotplug.rst |  2 +-
 lib/eal/common/eal_common_dev.c          |  2 +-
 lib/eal/include/bus_driver.h             | 13 -------------
 3 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/doc/guides/prog_guide/device_hotplug.rst b/doc/guides/prog_guide/device_hotplug.rst
index 9896a097f3..7eb7fbcc2b 100644
--- a/doc/guides/prog_guide/device_hotplug.rst
+++ b/doc/guides/prog_guide/device_hotplug.rst
@@ -234,7 +234,7 @@ When ``rte_dev_probe()`` is called, the following sequence occurs:
    and the attach operation fails if the device is not found.
 
 #. **Device Probe**:
-   The bus's ``plug()`` method is called, which triggers the device driver's probe function.
+   The bus's ``probe_device()`` method is called, which triggers the device driver's probe function.
    The probe function typically allocates device-specific resources,
    maps device memory regions, initializes device hardware,
    and registers the device with the appropriate subsystem (e.g., ethdev for network devices).
diff --git a/lib/eal/common/eal_common_dev.c b/lib/eal/common/eal_common_dev.c
index 48b631532a..2a2103ec57 100644
--- a/lib/eal/common/eal_common_dev.c
+++ b/lib/eal/common/eal_common_dev.c
@@ -193,7 +193,7 @@ local_dev_probe(const char *devargs, struct rte_device **new_dev)
 		goto err_devarg;
 
 	if (da->bus->probe_device == NULL) {
-		EAL_LOG(ERR, "Function plug not supported by bus (%s)",
+		EAL_LOG(ERR, "Function probe_device not supported by bus (%s)",
 			da->bus->name);
 		ret = -ENOTSUP;
 		goto err_devarg;
diff --git a/lib/eal/include/bus_driver.h b/lib/eal/include/bus_driver.h
index 0a7e23d98d..9711e6712b 100644
--- a/lib/eal/include/bus_driver.h
+++ b/lib/eal/include/bus_driver.h
@@ -75,19 +75,6 @@ typedef struct rte_device *
 (*rte_bus_find_device_t)(const struct rte_bus *bus, const struct rte_device *start,
 			 rte_dev_cmp_t cmp, const void *data);
 
-/**
- * Implementation specific probe function which is responsible for linking
- * devices on that bus with applicable drivers.
- *
- * @param dev
- *	Device pointer that was returned by a previous call to find_device.
- *
- * @return
- *	0 on success.
- *	!0 on error.
- */
-typedef int (*rte_bus_plug_t)(struct rte_device *dev);
-
 /**
  * Implementation specific probe function which is responsible for linking
  * devices on that bus with applicable drivers.
-- 
2.54.0


^ permalink raw reply related

* [PATCH v4 00/12] Bus cleanup infrastructure and fixes
From: David Marchand @ 2026-06-24 10:43 UTC (permalink / raw)
  To: dev; +Cc: thomas, stephen, bruce.richardson, fengchengwen, longli,
	hemant.agrawal
In-Reply-To: <20260611094551.1514962-1-david.marchand@redhat.com>

This is a followup of the previous bus refactoring.
See https://inbox.dpdk.org/dev/CAJFAV8zvFpLwz8SY8DUUezyJyM43eRZ17Yj30ex808eHC4ZE=g@mail.gmail.com/.

This series refactors the bus cleanup infrastructure to reduce code
duplication and fix resource leaks in several bus drivers.
It should address the leak Thomas pointed at.

The first part of the series (patches 1-6) addresses several bugs and
inconsistencies:
- Documentation and log message inconsistencies from earlier bus
  refactoring
- Device list management issues in dma/idxd and bus/vdev
- Resource leaks in PCI and VMBUS bus cleanup (mappings and interrupts)
- Deferred interrupt allocation to probe time (VMBUS)

The core infrastructure changes (patches 7-8) introduce the generic
cleanup framework:
- Refactors unplug operations to be the counterpart of probe_device
- Implements rte_bus_generic_cleanup() to centralize cleanup logic
- Adds .free_device operation to struct rte_bus

The final patches (9-10) convert the VMBUS bus to use the generic
cleanup helper.

After this series, most buses use the generic cleanup helper, eliminating
duplicated code and ensuring consistent cleanup behavior across the
codebase.

NXP bus drivers require more (leak) fixes and refactoring and
are left untouched.


-- 
David Marchand

Changes since v3:
- added fix on vdpa/nfp,

Changes since v2:
- moved ifpga interruption allocation,

Changes since v1:
- dropped all changes on DPAA and FSLMC bus,
- added one more cleanup on the first patch,
- changed coding style in rte_vdev_init,
- implemented explicit .free_device instead of hack for calling free(),
- reordered interrupt handle allocation in VMBUS bus,


David Marchand (12):
  bus: fix reference to plug callback
  dma/idxd: remove next pointer in bus specific device
  bus/vdev: remove driver setting in probe
  vdpa/nfp: fix double PCI unmap on unplug
  bus/pci: fix mapping leak in bus cleanup
  bus/vmbus: fix interrupt leak in cleanup
  bus/vmbus: allocate interrupt during probing
  bus/ifpga: allocate interrupt during probing
  bus: align unplug with device probe
  bus: implement cleanup in EAL
  bus/vmbus: store name in bus specific device
  bus/vmbus: support unplug

 doc/guides/prog_guide/device_hotplug.rst | 20 +++---
 doc/guides/rel_notes/release_26_07.rst   |  4 ++
 drivers/bus/auxiliary/auxiliary_common.c | 54 +++------------
 drivers/bus/cdx/cdx.c                    | 29 ++------
 drivers/bus/dpaa/dpaa_bus.c              |  4 +-
 drivers/bus/fslmc/fslmc_bus.c            |  9 +--
 drivers/bus/ifpga/ifpga_bus.c            | 88 ++++++++----------------
 drivers/bus/pci/pci_common.c             | 68 +++---------------
 drivers/bus/platform/platform.c          | 26 ++-----
 drivers/bus/uacce/uacce.c                | 59 +++-------------
 drivers/bus/vdev/vdev.c                  | 76 ++++++++------------
 drivers/bus/vmbus/bus_vmbus_driver.h     |  1 +
 drivers/bus/vmbus/linux/vmbus_bus.c      | 16 +----
 drivers/bus/vmbus/vmbus_common.c         | 58 +++++++++-------
 drivers/dma/idxd/idxd_bus.c              |  1 -
 drivers/vdpa/nfp/nfp_vdpa.c              |  4 +-
 lib/eal/common/eal_common_bus.c          | 33 ++++++++-
 lib/eal/common/eal_common_dev.c          | 10 +--
 lib/eal/include/bus_driver.h             | 51 +++++++++-----
 19 files changed, 235 insertions(+), 376 deletions(-)

-- 
2.54.0


^ permalink raw reply

* [PATCH v2 17/17] net/virtio: replace strncpy with strlcpy
From: Bruce Richardson @ 2026-06-24 10:36 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, stable, Maxime Coquelin, Chenbo Xia,
	David Marchand
In-Reply-To: <20260624103658.792750-1-bruce.richardson@intel.com>

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

Fixes: b72099be7f27 ("net/virtio-user: fix init when using existing tap")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/virtio/virtio_user/vhost_kernel_tap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
index 2431d00c33..da55aba505 100644
--- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
+++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
@@ -60,7 +60,7 @@ vhost_tap_open(const char *ifname, unsigned int r_flags, bool multi_queue)
 
 retry_mono_q:
 	memset(&ifr, 0, sizeof(ifr));
-	strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
+	strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
 	ifr.ifr_flags = r_flags;
 	if (multi_queue)
 		ifr.ifr_flags |= IFF_MULTI_QUEUE;
-- 
2.53.0


^ permalink raw reply related

* [PATCH v2 16/17] net/vhost: replace strncpy with strlcpy
From: Bruce Richardson @ 2026-06-24 10:36 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, stable, Maxime Coquelin, Chenbo Xia
In-Reply-To: <20260624103658.792750-1-bruce.richardson@intel.com>

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

Fixes: 2e16597c4bda ("net/vhost: move to vhost library statistics API")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/vhost/rte_eth_vhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 05940f2461..82e9fc929a 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -209,7 +209,7 @@ vhost_dev_xstats_get_names(struct rte_eth_dev *dev,
 	}
 
 	for (i = 0; i < count; i++)
-		strncpy(xstats_names[i].name, name[i].name, RTE_ETH_XSTATS_NAME_SIZE);
+		strlcpy(xstats_names[i].name, name[i].name, RTE_ETH_XSTATS_NAME_SIZE);
 
 	free(name);
 
-- 
2.53.0


^ permalink raw reply related

* [PATCH v2 15/17] net/softnic: replace strncpy with strlcpy
From: Bruce Richardson @ 2026-06-24 10:36 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, stable, Cristian Dumitrescu, Jasvinder Singh
In-Reply-To: <20260624103658.792750-1-bruce.richardson@intel.com>

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

Fixes: 7709a63bf178 ("net/softnic: add connection agent")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/softnic/conn.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/softnic/conn.c b/drivers/net/softnic/conn.c
index 5b031358d5..398f864d16 100644
--- a/drivers/net/softnic/conn.c
+++ b/drivers/net/softnic/conn.c
@@ -15,6 +15,8 @@
 #include <arpa/inet.h>
 #include <errno.h>
 
+#include <rte_string_fns.h>
+
 #include "conn.h"
 
 #define MSG_CMD_TOO_LONG "Command too long."
@@ -116,8 +118,8 @@ softnic_conn_init(struct softnic_conn_params *p)
 	}
 
 	/* Fill in */
-	strncpy(conn->welcome, p->welcome, CONN_WELCOME_LEN_MAX);
-	strncpy(conn->prompt, p->prompt, CONN_PROMPT_LEN_MAX);
+	strlcpy(conn->welcome, p->welcome, CONN_WELCOME_LEN_MAX + 1);
+	strlcpy(conn->prompt, p->prompt, CONN_PROMPT_LEN_MAX + 1);
 	conn->buf_size = p->buf_size;
 	conn->msg_in_len_max = p->msg_in_len_max;
 	conn->msg_out_len_max = p->msg_out_len_max;
-- 
2.53.0


^ permalink raw reply related

* [PATCH v2 14/17] net/qede: replace strncpy with strlcpy
From: Bruce Richardson @ 2026-06-24 10:36 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, stable, Devendra Singh Rawat, Alok Prasad,
	Harish Patil, Rasesh Mody, Sony Chacko
In-Reply-To: <20260624103658.792750-1-bruce.richardson@intel.com>

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

Fixes: 2ea6f76aff40 ("qede: add core driver")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/qede/qede_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index 4efc2dd349..2f37f956cb 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -2596,7 +2596,7 @@ static int qede_common_dev_init(struct rte_eth_dev *eth_dev, bool is_vf)
 	params.drv_minor = QEDE_PMD_VERSION_MINOR;
 	params.drv_rev = QEDE_PMD_VERSION_REVISION;
 	params.drv_eng = QEDE_PMD_VERSION_PATCH;
-	strncpy((char *)params.name, QEDE_PMD_VER_PREFIX,
+	strlcpy((char *)params.name, QEDE_PMD_VER_PREFIX,
 		QEDE_PMD_DRV_VER_STR_SIZE);
 
 	qede_assign_rxtx_handlers(eth_dev, true);
-- 
2.53.0


^ permalink raw reply related

* [PATCH v2 13/17] net/nfp: replace strncpy with strlcpy
From: Bruce Richardson @ 2026-06-24 10:36 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, stable, Chaoyong He, Alejandro Lucero
In-Reply-To: <20260624103658.792750-1-bruce.richardson@intel.com>

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

Fixes: c7e9729da6b5 ("net/nfp: support CPP")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/nfp/nfpcore/nfp_resource.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/nfp/nfpcore/nfp_resource.c b/drivers/net/nfp/nfpcore/nfp_resource.c
index 6437a78852..781350c46f 100644
--- a/drivers/net/nfp/nfpcore/nfp_resource.c
+++ b/drivers/net/nfp/nfpcore/nfp_resource.c
@@ -168,7 +168,7 @@ nfp_resource_acquire(struct nfp_cpp *cpp,
 
 	memset(res, 0, sizeof(*res));
 
-	strncpy(res->name, name, NFP_RESOURCE_ENTRY_NAME_SZ);
+	strlcpy(res->name, name, sizeof(res->name));
 
 	dev_mutex = nfp_cpp_mutex_alloc(cpp, NFP_RESOURCE_TBL_TARGET,
 			NFP_RESOURCE_TBL_BASE, NFP_RESOURCE_TBL_KEY);
-- 
2.53.0


^ permalink raw reply related

* [PATCH v2 12/17] net/mlx5: replace strncpy with strlcpy
From: Bruce Richardson @ 2026-06-24 10:36 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, stable, Dariusz Sosnowski, Viacheslav Ovsiienko,
	Bing Zhao, Ori Kam, Suanming Mou, Matan Azrad, Michael Baum,
	Gregory Etelson
In-Reply-To: <20260624103658.792750-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


^ permalink raw reply related

* [PATCH v2 11/17] net/mlx4: replace strncpy with strlcpy
From: Bruce Richardson @ 2026-06-24 10:36 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, stable, Matan Azrad, Viacheslav Ovsiienko,
	Adrien Mazarguil
In-Reply-To: <20260624103658.792750-1-bruce.richardson@intel.com>

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

Fixes: 61cbdd419478 ("net/mlx4: separate device control functions")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/mlx4/mlx4_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c
index efc6ee4577..ff353af224 100644
--- a/drivers/net/mlx4/mlx4_ethdev.c
+++ b/drivers/net/mlx4/mlx4_ethdev.c
@@ -127,7 +127,7 @@ mlx4_get_ifname(const struct mlx4_priv *priv, char (*ifname)[IF_NAMESIZE])
 		rte_errno = ENODEV;
 		return -rte_errno;
 	}
-	strncpy(*ifname, match, sizeof(*ifname));
+	strlcpy(*ifname, match, sizeof(*ifname));
 	return 0;
 }
 
-- 
2.53.0


^ permalink raw reply related

* [PATCH v2 10/17] net/ionic: replace strncpy with strlcpy
From: Bruce Richardson @ 2026-06-24 10:36 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, stable, Andrew Boyer, Alfredo Cardigliano,
	Shannon Nelson
In-Reply-To: <20260624103658.792750-1-bruce.richardson@intel.com>

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

Fixes: 5ef518098ec6 ("net/ionic: register and initialize adapter")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/ionic/ionic_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ionic/ionic_main.c b/drivers/net/ionic/ionic_main.c
index 814bb3b8f4..d5545b1ecb 100644
--- a/drivers/net/ionic/ionic_main.c
+++ b/drivers/net/ionic/ionic_main.c
@@ -393,8 +393,8 @@ ionic_identify(struct ionic_adapter *adapter)
 	ident->drv.kernel_ver = 0;
 	snprintf(ident->drv.kernel_ver_str,
 		sizeof(ident->drv.kernel_ver_str), "DPDK");
-	strncpy(ident->drv.driver_ver_str, IONIC_DRV_VERSION,
-		sizeof(ident->drv.driver_ver_str) - 1);
+	strlcpy(ident->drv.driver_ver_str, IONIC_DRV_VERSION,
+		sizeof(ident->drv.driver_ver_str));
 
 	nwords = RTE_MIN(drv_size, cmd_size);
 	for (i = 0; i < nwords; i++)
-- 
2.53.0


^ permalink raw reply related

* [PATCH v2 09/17] net/dpaa: replace strncpy with strlcpy
From: Bruce Richardson @ 2026-06-24 10:36 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, stable, Hemant Agrawal, Sachin Saxena,
	Vanshika Shukla, Rohit Raj
In-Reply-To: <20260624103658.792750-1-bruce.richardson@intel.com>

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

Fixes: ee0fa7552a0a ("net/dpaa: forbid MTU configuration for shared interface")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/dpaa/dpaa_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 9f976d179b..8b1072f9b9 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -247,7 +247,7 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)
 			DPAA_PMD_ERR("Cannot open IF socket");
 			return -errno;
 		}
-		strncpy(ifr.ifr_name, dpaa_intf->name, IFNAMSIZ - 1);
+		strlcpy(ifr.ifr_name, dpaa_intf->name, IFNAMSIZ);
 
 		if (ioctl(socket_fd, SIOCGIFMTU, &ifr) < 0) {
 			DPAA_PMD_ERR("Cannot get interface mtu");
-- 
2.53.0


^ permalink raw reply related

* [PATCH v2 08/17] net/cnxk: replace strncpy with strlcpy
From: Bruce Richardson @ 2026-06-24 10:36 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, stable, Nithin Dabilpuram, Kiran Kumar K,
	Sunil Kumar Kori, Satha Rao, Harman Kalra
In-Reply-To: <20260624103658.792750-1-bruce.richardson@intel.com>

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

Fixes: 804c585658ea ("net/cnxk: add representor control plane")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/cnxk/cnxk_eswitch.c | 4 ++--
 drivers/net/cnxk/cnxk_rep_msg.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/cnxk/cnxk_eswitch.c b/drivers/net/cnxk/cnxk_eswitch.c
index e45c7dfd07..50c3e54109 100644
--- a/drivers/net/cnxk/cnxk_eswitch.c
+++ b/drivers/net/cnxk/cnxk_eswitch.c
@@ -124,8 +124,8 @@ cnxk_eswitch_dev_remove(struct rte_pci_device *pci_dev)
 				}
 				sun.sun_family = AF_UNIX;
 				sunlen = sizeof(struct sockaddr_un);
-				strncpy(sun.sun_path, CNXK_ESWITCH_CTRL_MSG_SOCK_PATH,
-					sizeof(sun.sun_path) - 1);
+				strlcpy(sun.sun_path, CNXK_ESWITCH_CTRL_MSG_SOCK_PATH,
+					sizeof(sun.sun_path));
 
 				if (connect(sock_fd, (struct sockaddr *)&sun, sunlen) < 0) {
 					plt_err("Failed to connect socket: %s, err %d",
diff --git a/drivers/net/cnxk/cnxk_rep_msg.c b/drivers/net/cnxk/cnxk_rep_msg.c
index a222e2b5cd..7b92e7a5f7 100644
--- a/drivers/net/cnxk/cnxk_rep_msg.c
+++ b/drivers/net/cnxk/cnxk_rep_msg.c
@@ -138,7 +138,7 @@ open_socket_ctrl_channel(void)
 
 	memset(&un, 0, sizeof(struct sockaddr_un));
 	un.sun_family = AF_UNIX;
-	strncpy(un.sun_path, CNXK_ESWITCH_CTRL_MSG_SOCK_PATH, sizeof(un.sun_path) - 1);
+	strlcpy(un.sun_path, CNXK_ESWITCH_CTRL_MSG_SOCK_PATH, sizeof(un.sun_path));
 
 	if (bind(sock_fd, (struct sockaddr *)&un, sizeof(un)) < 0) {
 		plt_err("Failed to bind %s: %s", un.sun_path, strerror(errno));
-- 
2.53.0


^ permalink raw reply related

* [PATCH v2 07/17] net/bnx2x: replace strncpy with strlcpy
From: Bruce Richardson @ 2026-06-24 10:36 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, stable, Julien Aube, Stephen Hemminger,
	Harish Patil
In-Reply-To: <20260624103658.792750-1-bruce.richardson@intel.com>

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

Fixes: 540a211084a7 ("bnx2x: driver core")
Cc: stable@dpdk.org

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

diff --git a/drivers/net/bnx2x/bnx2x.c b/drivers/net/bnx2x/bnx2x.c
index 8790c858d5..1a3956b224 100644
--- a/drivers/net/bnx2x/bnx2x.c
+++ b/drivers/net/bnx2x/bnx2x.c
@@ -3596,7 +3596,7 @@ static void bnx2x_drv_info_ether_stat(struct bnx2x_softc *sc)
 {
 	struct eth_stats_info *ether_stat = &sc->sp->drv_info_to_mcp.ether_stat;
 
-	strncpy(ether_stat->version, BNX2X_DRIVER_VERSION,
+	strlcpy(ether_stat->version, BNX2X_DRIVER_VERSION,
 		ETH_STAT_INFO_VERSION_LEN);
 
 	sc->sp_objs[0].mac_obj.get_n_elements(sc, &sc->sp_objs[0].mac_obj,
diff --git a/drivers/net/bnx2x/bnx2x_vfpf.c b/drivers/net/bnx2x/bnx2x_vfpf.c
index 5411df3a38..23f576877f 100644
--- a/drivers/net/bnx2x/bnx2x_vfpf.c
+++ b/drivers/net/bnx2x/bnx2x_vfpf.c
@@ -303,7 +303,7 @@ int bnx2x_vf_get_resources(struct bnx2x_softc *sc, uint8_t tx_count, uint8_t rx_
 
 	PMD_DRV_LOG(DEBUG, sc, "status block count = %d, base status block = %x",
 		sc->igu_sb_cnt, sc->igu_base_sb);
-	strncpy(sc->fw_ver, sc_resp.fw_ver, sizeof(sc->fw_ver));
+	strlcpy(sc->fw_ver, sc_resp.fw_ver, sizeof(sc->fw_ver));
 
 	if (rte_is_valid_assigned_ether_addr(&sc_resp.resc.current_mac_addr))
 		rte_ether_addr_copy(&sc_resp.resc.current_mac_addr,
-- 
2.53.0


^ permalink raw reply related

* [PATCH v2 06/17] net/ark: replace strncpy with strlcpy
From: Bruce Richardson @ 2026-06-24 10:36 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, stable, Shepard Siegel, Ed Czeck, John Miller
In-Reply-To: <20260624103658.792750-1-bruce.richardson@intel.com>

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

Fixes: 1131cbf0fb2b ("net/ark: stub PMD for Atomic Rules Arkville")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/ark/ark_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
index 9272e271e6..d6b1abf383 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -929,7 +929,7 @@ process_file_args(const char *key, const char *value, void *extra_args)
 			return -1;
 		}
 		if (first) {
-			strncpy(args, line, ARK_MAX_ARG_LEN);
+			strlcpy(args, line, ARK_MAX_ARG_LEN);
 			first = 0;
 		} else {
 			strncat(args, line, ARK_MAX_ARG_LEN);
-- 
2.53.0


^ permalink raw reply related

* [PATCH v2 05/17] event/cnxk: replace strncpy with strlcpy
From: Bruce Richardson @ 2026-06-24 10:36 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, stable, Pavan Nikhilesh, Shijith Thotton
In-Reply-To: <20260624103658.792750-1-bruce.richardson@intel.com>

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

Fixes: b5a52c9d97e2 ("event/cnxk: add event port and queue xstats")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/event/cnxk/cnxk_eventdev_stats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/event/cnxk/cnxk_eventdev_stats.c b/drivers/event/cnxk/cnxk_eventdev_stats.c
index 6dea91aedf..288d34bd7e 100644
--- a/drivers/event/cnxk/cnxk_eventdev_stats.c
+++ b/drivers/event/cnxk/cnxk_eventdev_stats.c
@@ -283,7 +283,7 @@ cnxk_sso_xstats_get_names(const struct rte_eventdev *event_dev,
 
 	for (i = 0; i < xstats_mode_count; i++) {
 		xidx = i + start_offset;
-		strncpy(xstats_names[i].name, xstats_names_copy[xidx].name,
+		strlcpy(xstats_names[i].name, xstats_names_copy[xidx].name,
 			sizeof(xstats_names[i].name));
 		ids[i] = xidx;
 	}
-- 
2.53.0


^ permalink raw reply related

* [PATCH v2 04/17] crypto/scheduler: replace strncpy with strlcpy
From: Bruce Richardson @ 2026-06-24 10:36 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, stable, Kai Ji, Fan Zhang, Pablo de Lara
In-Reply-To: <20260624103658.792750-1-bruce.richardson@intel.com>

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

Fixes: 50e14527b9d1 ("crypto/scheduler: improve parameters parsing")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/crypto/scheduler/scheduler_pmd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/scheduler/scheduler_pmd.c b/drivers/crypto/scheduler/scheduler_pmd.c
index 95ce893f05..ceaefa329b 100644
--- a/drivers/crypto/scheduler/scheduler_pmd.c
+++ b/drivers/crypto/scheduler/scheduler_pmd.c
@@ -229,10 +229,10 @@ cryptodev_scheduler_create(const char *name,
 			return -ENOMEM;
 		}
 
-		strncpy(sched_ctx->init_worker_names[
+		strlcpy(sched_ctx->init_worker_names[
 					sched_ctx->nb_init_workers],
 				init_params->worker_names[i],
-				RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN - 1);
+				RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN);
 
 		sched_ctx->nb_init_workers++;
 	}
@@ -443,8 +443,8 @@ parse_worker_arg(const char *key __rte_unused,
 		return -ENOMEM;
 	}
 
-	strncpy(param->worker_names[param->nb_workers++], value,
-			RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN - 1);
+	strlcpy(param->worker_names[param->nb_workers++], value,
+			RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN);
 
 	return 0;
 }
-- 
2.53.0


^ permalink raw reply related

* [PATCH v2 03/17] crypto/mvsam: replace strncpy with strlcpy
From: Bruce Richardson @ 2026-06-24 10:36 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, stable, Michael Shamis, Liron Himi,
	Pablo de Lara, Tomasz Duszynski
In-Reply-To: <20260624103658.792750-1-bruce.richardson@intel.com>

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

Fixes: 25b05a1c806b ("crypto/mvsam: parse max number of sessions")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/crypto/mvsam/rte_mrvl_pmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c b/drivers/crypto/mvsam/rte_mrvl_pmd.c
index a824719fb0..65a63c9d62 100644
--- a/drivers/crypto/mvsam/rte_mrvl_pmd.c
+++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c
@@ -1146,7 +1146,7 @@ parse_name_arg(const char *key __rte_unused,
 		return -EINVAL;
 	}
 
-	strncpy(params->name, value, RTE_CRYPTODEV_NAME_MAX_LEN);
+	strlcpy(params->name, value, RTE_CRYPTODEV_NAME_MAX_LEN);
 
 	return 0;
 }
-- 
2.53.0


^ permalink raw reply related

* [PATCH v2 02/17] common/mlx5: replace strncpy with strlcpy
From: Bruce Richardson @ 2026-06-24 10:36 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, stable, Dariusz Sosnowski, Viacheslav Ovsiienko,
	Bing Zhao, Ori Kam, Suanming Mou, Matan Azrad, Maxime Coquelin
In-Reply-To: <20260624103658.792750-1-bruce.richardson@intel.com>

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

Fixes: aec086c9f1c8 ("common/mlx5: share kernel interface name getter")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/common/mlx5/linux/mlx5_common_os.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c
index e3db6c4124..53bcc9b844 100644
--- a/drivers/common/mlx5/linux/mlx5_common_os.c
+++ b/drivers/common/mlx5/linux/mlx5_common_os.c
@@ -231,7 +231,7 @@ mlx5_get_ifname_sysfs(const char *ibdev_path, char *ifname)
 		rte_errno = ENOENT;
 		return -rte_errno;
 	}
-	strncpy(ifname, match, IF_NAMESIZE);
+	strlcpy(ifname, match, IF_NAMESIZE);
 	return 0;
 }
 
-- 
2.53.0


^ permalink raw reply related

* [PATCH v2 01/17] common/cnxk: replace strncpy with strlcpy
From: Bruce Richardson @ 2026-06-24 10:36 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, stable, Nithin Dabilpuram, Kiran Kumar K,
	Sunil Kumar Kori, Satha Rao, Harman Kalra, Jerin Jacob,
	Srikanth Yalavarthi, Rakesh Kudurumalla
In-Reply-To: <20260624103658.792750-1-bruce.richardson@intel.com>

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

Fixes: 014a9e222bac ("common/cnxk: add model init and IO handling API")
Fixes: b315581c66dc ("common/cnxk: skip probing SoC environment for CN9K")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/common/cnxk/roc_model.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/common/cnxk/roc_model.c b/drivers/common/cnxk/roc_model.c
index f0312a5400..ddd7ee8634 100644
--- a/drivers/common/cnxk/roc_model.c
+++ b/drivers/common/cnxk/roc_model.c
@@ -211,15 +211,15 @@ populate_model(struct roc_model *model, uint32_t midr)
 		if (model_db[i].impl == impl && model_db[i].part == part &&
 		    model_db[i].major == major && model_db[i].minor == minor) {
 			model->flag = model_db[i].flag;
-			strncpy(model->name, model_db[i].name,
-				ROC_MODEL_STR_LEN_MAX - 1);
+			strlcpy(model->name, model_db[i].name,
+				ROC_MODEL_STR_LEN_MAX);
 			found = true;
 			break;
 		}
 not_found:
 	if (!found) {
 		model->flag = 0;
-		strncpy(model->name, "unknown", ROC_MODEL_STR_LEN_MAX - 1);
+		strlcpy(model->name, "unknown", ROC_MODEL_STR_LEN_MAX);
 		plt_err("Invalid RoC model (impl=0x%x, part=0x%x, major=0x%x, minor=0x%x)",
 			impl, part, major, minor);
 	}
@@ -297,7 +297,7 @@ of_env_get(struct roc_model *model)
 	FILE *fp;
 
 	if (access(path, F_OK) != 0) {
-		strncpy(model->env, "HW_PLATFORM", ROC_MODEL_STR_LEN_MAX - 1);
+		strlcpy(model->env, "HW_PLATFORM", ROC_MODEL_STR_LEN_MAX);
 		model->flag |= ROC_ENV_HW;
 		return;
 	}
-- 
2.53.0


^ permalink raw reply related

* [PATCH v2 00/17] drivers: replace strncpy with strlcpy
From: Bruce Richardson @ 2026-06-24 10:36 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson
In-Reply-To: <20260623165150.765443-1-bruce.richardson@intel.com>

Many uses of strncpy in DPDK drivers can be directly replaced by
a call to strlcpy instead, which is safer in that it always null-
terminates the string. This AI assisted patchset makes those
simple replacements, adjusting lengths as appropriate.

After this set, there are still a number of drivers with strncpy calls
in them, but those are not simple strncpy->strlcpy replacements, so
left for later rework.

v2:
* fix incorrect commit ids for fixlines.
* fix build errors due to missing rte_string_fns.h header include

Bruce Richardson (17):
  common/cnxk: replace strncpy with strlcpy
  common/mlx5: replace strncpy with strlcpy
  crypto/mvsam: replace strncpy with strlcpy
  crypto/scheduler: replace strncpy with strlcpy
  event/cnxk: replace strncpy with strlcpy
  net/ark: replace strncpy with strlcpy
  net/bnx2x: replace strncpy with strlcpy
  net/cnxk: replace strncpy with strlcpy
  net/dpaa: replace strncpy with strlcpy
  net/ionic: replace strncpy with strlcpy
  net/mlx4: replace strncpy with strlcpy
  net/mlx5: replace strncpy with strlcpy
  net/nfp: replace strncpy with strlcpy
  net/qede: replace strncpy with strlcpy
  net/softnic: replace strncpy with strlcpy
  net/vhost: replace strncpy with strlcpy
  net/virtio: replace strncpy with strlcpy

 drivers/common/cnxk/roc_model.c                   | 8 ++++----
 drivers/common/mlx5/linux/mlx5_common_os.c        | 2 +-
 drivers/crypto/mvsam/rte_mrvl_pmd.c               | 2 +-
 drivers/crypto/scheduler/scheduler_pmd.c          | 8 ++++----
 drivers/event/cnxk/cnxk_eventdev_stats.c          | 2 +-
 drivers/net/ark/ark_ethdev.c                      | 2 +-
 drivers/net/bnx2x/bnx2x.c                         | 2 +-
 drivers/net/bnx2x/bnx2x_vfpf.c                    | 2 +-
 drivers/net/cnxk/cnxk_eswitch.c                   | 4 ++--
 drivers/net/cnxk/cnxk_rep_msg.c                   | 2 +-
 drivers/net/dpaa/dpaa_ethdev.c                    | 2 +-
 drivers/net/ionic/ionic_main.c                    | 4 ++--
 drivers/net/mlx4/mlx4_ethdev.c                    | 2 +-
 drivers/net/mlx5/mlx5.c                           | 8 ++++----
 drivers/net/mlx5/windows/mlx5_ethdev_os.c         | 2 +-
 drivers/net/nfp/nfpcore/nfp_resource.c            | 2 +-
 drivers/net/qede/qede_ethdev.c                    | 2 +-
 drivers/net/softnic/conn.c                        | 6 ++++--
 drivers/net/vhost/rte_eth_vhost.c                 | 2 +-
 drivers/net/virtio/virtio_user/vhost_kernel_tap.c | 2 +-
 20 files changed, 34 insertions(+), 32 deletions(-)

--
2.53.0


^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox