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 3E14043329; Tue, 14 Nov 2023 13:40:27 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E841F42D0C; Tue, 14 Nov 2023 13:36:43 +0100 (CET) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 32F1F40648 for ; Tue, 14 Nov 2023 13:36:00 +0100 (CET) Received: from dggpeml500011.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SV5Kh4c9Lz1P8Jj; Tue, 14 Nov 2023 20:32:40 +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 20:35:58 +0800 From: Dengdui Huang To: CC: , , , , Subject: [PATCH v3 39/42] raw/ifpga: use rte strerror Date: Tue, 14 Nov 2023 20:35:49 +0800 Message-ID: <20231114123552.398072-40-huangdengdui@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20231114123552.398072-1-huangdengdui@huawei.com> References: <20231114082539.1858594-44-huangdengdui@huawei.com> <20231114123552.398072-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: dggems706-chm.china.huawei.com (10.3.19.183) 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/raw/ifpga/afu_pmd_n3000.c | 5 +++-- drivers/raw/ifpga/base/ifpga_fme_rsu.c | 12 +++++++----- drivers/raw/ifpga/ifpga_rawdev.c | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/raw/ifpga/afu_pmd_n3000.c b/drivers/raw/ifpga/afu_pmd_n3000.c index 67b3941265..d7302edc3f 100644 --- a/drivers/raw/ifpga/afu_pmd_n3000.c +++ b/drivers/raw/ifpga/afu_pmd_n3000.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "afu_pmd_core.h" #include "afu_pmd_n3000.h" @@ -693,7 +694,7 @@ static int poll_interrupt(struct dma_afu_ctx *ctx) pfd.events = POLLIN; poll_ret = poll(&pfd, 1, DMA_TIMEOUT_MSEC); if (poll_ret < 0) { - IFPGA_RAWDEV_PMD_ERR("Error %s", strerror(errno)); + IFPGA_RAWDEV_PMD_ERR("Error %s", rte_strerror(errno)); ret = -EFAULT; goto out; } else if (poll_ret == 0) { @@ -708,7 +709,7 @@ static int poll_interrupt(struct dma_afu_ctx *ctx) ret = 0; } else { IFPGA_RAWDEV_PMD_ERR("Failed %s", bytes_read > 0 ? - strerror(errno) : "zero bytes read"); + rte_strerror(errno) : "zero bytes read"); ret = -EIO; } } diff --git a/drivers/raw/ifpga/base/ifpga_fme_rsu.c b/drivers/raw/ifpga/base/ifpga_fme_rsu.c index f147aaa1e8..8e8a611f9a 100644 --- a/drivers/raw/ifpga/base/ifpga_fme_rsu.c +++ b/drivers/raw/ifpga/base/ifpga_fme_rsu.c @@ -7,6 +7,8 @@ #include #include "ifpga_sec_mgr.h" +#include + static struct ifpga_sec_mgr *sec_mgr; static void set_rsu_control(struct ifpga_sec_mgr *smgr, uint32_t ctrl) @@ -112,7 +114,7 @@ static int write_flash_image(struct ifpga_sec_mgr *smgr, const char *image, if (fd < 0) { dev_err(smgr, "Failed to open \'%s\' for RD [e:%s]\n", - image, strerror(errno)); + image, rte_strerror(errno)); return -EIO; } @@ -130,14 +132,14 @@ static int write_flash_image(struct ifpga_sec_mgr *smgr, const char *image, IFPGA_RSU_DATA_BLK_SIZE : length; if (lseek(fd, offset, SEEK_SET) < 0) { dev_err(smgr, "Failed to seek in \'%s\' [e:%s]\n", - image, strerror(errno)); + image, rte_strerror(errno)); ret = -EIO; goto end; } read_size = read(fd, buf, to_transfer); if (read_size < 0) { dev_err(smgr, "Failed to read from \'%s\' [e:%s]\n", - image, strerror(errno)); + image, rte_strerror(errno)); ret = -EIO; goto end; } @@ -316,7 +318,7 @@ int fpga_update_flash(struct ifpga_fme_hw *fme, const char *image, if (fd < 0) { dev_err(smgr, "Failed to open \'%s\' for RD [e:%s]\n", - image, strerror(errno)); + image, rte_strerror(errno)); return -EIO; } len = lseek(fd, 0, SEEK_END); @@ -325,7 +327,7 @@ int fpga_update_flash(struct ifpga_fme_hw *fme, const char *image, if (len < 0) { dev_err(smgr, "Failed to get file length of \'%s\' [e:%s]\n", - image, strerror(errno)); + image, rte_strerror(errno)); return -EIO; } if (len == 0) { diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c index f89bd3f9e2..56d3ec02eb 100644 --- a/drivers/raw/ifpga/ifpga_rawdev.c +++ b/drivers/raw/ifpga/ifpga_rawdev.c @@ -847,7 +847,7 @@ rte_fpga_do_pr(struct rte_rawdev *rawdev, int port_id, if (file_fd < 0) { IFPGA_RAWDEV_PMD_ERR("%s: open file error: %s\n", __func__, file_name); - IFPGA_RAWDEV_PMD_ERR("Message : %s\n", strerror(errno)); + IFPGA_RAWDEV_PMD_ERR("Message : %s\n", rte_strerror(errno)); return -EINVAL; } ret = stat(file_name, &file_stat); -- 2.33.0