[v4,10/42] bus/cdx: use rte strerror

Message ID 20241023082852.2780488-11-huangdengdui@huawei.com (mailing list archive)
State Changes Requested, archived
Delegated to: Thomas Monjalon
Headers
Series replace strerror |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

huangdengdui Oct. 23, 2024, 8:28 a.m. UTC
The function strerror() is insecure in a multi-thread environment.
This patch uses rte_strerror() to replace it.

Cc: stable@dpdk.org

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
---
 drivers/bus/cdx/cdx.c      |  2 +-
 drivers/bus/cdx/cdx_vfio.c | 13 +++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)
  

Patch

diff --git a/drivers/bus/cdx/cdx.c b/drivers/bus/cdx/cdx.c
index 62b108e082..747f53b17f 100644
--- a/drivers/bus/cdx/cdx.c
+++ b/drivers/bus/cdx/cdx.c
@@ -271,7 +271,7 @@  cdx_scan(void)
 	dir = opendir(RTE_CDX_BUS_DEVICES_PATH);
 	if (dir == NULL) {
 		CDX_BUS_INFO("%s(): opendir failed: %s", __func__,
-			strerror(errno));
+			rte_strerror(errno));
 		return 0;
 	}
 
diff --git a/drivers/bus/cdx/cdx_vfio.c b/drivers/bus/cdx/cdx_vfio.c
index 664f267471..87e69e0082 100644
--- a/drivers/bus/cdx/cdx_vfio.c
+++ b/drivers/bus/cdx/cdx_vfio.c
@@ -20,6 +20,7 @@ 
 #include <rte_eal_paging.h>
 #include <rte_malloc.h>
 #include <rte_vfio.h>
+#include <rte_errno.h>
 
 #include "bus_cdx_driver.h"
 #include "cdx_logs.h"
@@ -204,7 +205,7 @@  cdx_vfio_setup_interrupts(struct rte_cdx_device *dev, int vfio_dev_fd,
 		ret = ioctl(vfio_dev_fd, VFIO_DEVICE_GET_IRQ_INFO, &irq);
 		if (ret < 0) {
 			CDX_BUS_ERR("Cannot get VFIO IRQ info, error %i (%s)",
-				errno, strerror(errno));
+				errno, rte_strerror(errno));
 			return -1;
 		}
 
@@ -222,7 +223,7 @@  cdx_vfio_setup_interrupts(struct rte_cdx_device *dev, int vfio_dev_fd,
 		fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
 		if (fd < 0) {
 			CDX_BUS_ERR("Cannot set up eventfd, error %i (%s)",
-				errno, strerror(errno));
+				errno, rte_strerror(errno));
 			return -1;
 		}
 
@@ -255,7 +256,7 @@  cdx_vfio_setup_device(struct rte_cdx_device *dev, int vfio_dev_fd,
 	 */
 	if (ioctl(vfio_dev_fd, VFIO_DEVICE_RESET) && errno != EINVAL) {
 		CDX_BUS_ERR("Unable to reset device! Error: %d (%s)", errno,
-			strerror(errno));
+			rte_strerror(errno));
 		return -1;
 	}
 
@@ -423,7 +424,7 @@  cdx_vfio_map_resource_primary(struct rte_cdx_device *dev)
 		ret = cdx_vfio_get_region_info(vfio_dev_fd, &reg, i);
 		if (ret < 0) {
 			CDX_BUS_ERR("%s cannot get device region info error %i (%s)",
-				dev_name, errno, strerror(errno));
+				dev_name, errno, rte_strerror(errno));
 			goto err_vfio_res;
 		}
 
@@ -451,7 +452,7 @@  cdx_vfio_map_resource_primary(struct rte_cdx_device *dev)
 		ret = cdx_vfio_mmap_resource(vfio_dev_fd, vfio_res, i, 0);
 		if (ret < 0) {
 			CDX_BUS_ERR("%s mapping region %i failed: %s",
-				cdx_addr, i, strerror(errno));
+				cdx_addr, i, rte_strerror(errno));
 			free(reg);
 			goto err_vfio_res;
 		}
@@ -519,7 +520,7 @@  cdx_vfio_map_resource_secondary(struct rte_cdx_device *dev)
 		ret = cdx_vfio_mmap_resource(vfio_dev_fd, vfio_res, i, MAP_FIXED);
 		if (ret < 0) {
 			CDX_BUS_ERR("%s mapping MMIO region %i failed: %s",
-				dev_name, i, strerror(errno));
+				dev_name, i, rte_strerror(errno));
 			goto err_vfio_dev_fd;
 		}