From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6F18043325; Tue, 14 Nov 2023 09:26:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5177F406BC; Tue, 14 Nov 2023 09:25:57 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 1C7CD4027B for ; Tue, 14 Nov 2023 09:25:43 +0100 (CET) Received: from dggpeml500011.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4STzrJ4V5HzWhKY; Tue, 14 Nov 2023 16:25:20 +0800 (CST) Received: from localhost.huawei.com (10.50.165.33) by dggpeml500011.china.huawei.com (7.185.36.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 14 Nov 2023 16:25:41 +0800 From: Dengdui Huang To: CC: , , , , Subject: [PATCH 11/43] bus/cdx: use rte strerror Date: Tue, 14 Nov 2023 16:25:07 +0800 Message-ID: <20231114082539.1858594-12-huangdengdui@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20231114082539.1858594-1-huangdengdui@huawei.com> References: <20231114082539.1858594-1-huangdengdui@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.50.165.33] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500011.china.huawei.com (7.185.36.84) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Acked-by: Chengwen Feng --- 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 #include #include +#include #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