The function strerror() is insecure in a multi-thread environment. This patch uses rte_strerror() to replace it.
Cc: sta...@dpdk.org Signed-off-by: Dengdui Huang <huangdeng...@huawei.com> Acked-by: Chengwen Feng <fengcheng...@huawei.com> --- drivers/bus/cdx/cdx.c | 2 +- drivers/bus/cdx/cdx_vfio.c | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/bus/cdx/cdx.c b/drivers/bus/cdx/cdx.c index 541aae76c3..a3161f8ee4 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 8a3ac0b995..6fb38abfac 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" @@ -198,7 +199,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; } @@ -216,7 +217,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; } @@ -252,7 +253,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; } @@ -410,7 +411,7 @@ cdx_vfio_map_resource_primary(struct rte_cdx_device *dev) ret = cdx_vfio_get_region_info(vfio_dev_fd, ®, 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; } @@ -438,7 +439,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; } @@ -506,7 +507,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; } -- 2.33.0