[v4,39/42] raw/ifpga: use rte strerror

Message ID 20241023082852.2780488-40-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/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(-)
  

Patch

diff --git a/drivers/raw/ifpga/afu_pmd_n3000.c b/drivers/raw/ifpga/afu_pmd_n3000.c
index 6aae1b224e..a67a427985 100644
--- a/drivers/raw/ifpga/afu_pmd_n3000.c
+++ b/drivers/raw/ifpga/afu_pmd_n3000.c
@@ -21,6 +21,7 @@ 
 #include <bus_pci_driver.h>
 #include <bus_ifpga_driver.h>
 #include <rte_rawdev.h>
+#include <rte_errno.h>
 
 #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 <unistd.h>
 #include "ifpga_sec_mgr.h"
 
+#include <rte_errno.h>
+
 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 5b9b596435..5982621373 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -848,7 +848,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",
 				__func__, file_name);
-		IFPGA_RAWDEV_PMD_ERR("Message : %s", strerror(errno));
+		IFPGA_RAWDEV_PMD_ERR("Message : %s", rte_strerror(errno));
 		return -EINVAL;
 	}
 	ret = stat(file_name, &file_stat);