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>
Acked-by: Morten Brørup <m...@smartsharesystems.com>
---
 drivers/dma/idxd/idxd_bus.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/dma/idxd/idxd_bus.c b/drivers/dma/idxd/idxd_bus.c
index ba8076715d..c4a2c6bb54 100644
--- a/drivers/dma/idxd/idxd_bus.c
+++ b/drivers/dma/idxd/idxd_bus.c
@@ -16,6 +16,7 @@
 #include <rte_log.h>
 #include <rte_dmadev_pmd.h>
 #include <rte_string_fns.h>
+#include <rte_errno.h>
 
 #include "idxd_internal.h"
 
@@ -145,7 +146,7 @@ read_wq_string(struct rte_dsa_device *dev, const char 
*filename,
        fd = open(sysfs_node, O_RDONLY);
        if (fd < 0) {
                IDXD_PMD_ERR("%s(): opening file '%s' failed: %s",
-                               __func__, sysfs_node, strerror(errno));
+                               __func__, sysfs_node, rte_strerror(errno));
                return -1;
        }
 
@@ -153,7 +154,7 @@ read_wq_string(struct rte_dsa_device *dev, const char 
*filename,
        close(fd);
        if (len < 0) {
                IDXD_PMD_ERR("%s(): error reading file '%s': %s",
-                               __func__, sysfs_node, strerror(errno));
+                               __func__, sysfs_node, rte_strerror(errno));
                return -1;
        }
        value[len] = '\0';
@@ -173,13 +174,13 @@ read_wq_int(struct rte_dsa_device *dev, const char 
*filename,
        f = fopen(sysfs_node, "r");
        if (f == NULL) {
                IDXD_PMD_ERR("%s(): opening file '%s' failed: %s",
-                               __func__, sysfs_node, strerror(errno));
+                               __func__, sysfs_node, rte_strerror(errno));
                return -1;
        }
 
        if (fscanf(f, "%d", value) != 1) {
                IDXD_PMD_ERR("%s(): error reading file '%s': %s",
-                               __func__, sysfs_node, strerror(errno));
+                               __func__, sysfs_node, rte_strerror(errno));
                ret = -1;
        }
 
@@ -200,13 +201,13 @@ read_device_int(struct rte_dsa_device *dev, const char 
*filename,
        f = fopen(sysfs_node, "r");
        if (f == NULL) {
                IDXD_PMD_ERR("%s(): opening file '%s' failed: %s",
-                               __func__, sysfs_node, strerror(errno));
+                               __func__, sysfs_node, rte_strerror(errno));
                return -1;
        }
 
        if (fscanf(f, "%d", value) != 1) {
                IDXD_PMD_ERR("%s(): error reading file '%s': %s",
-                               __func__, sysfs_node, strerror(errno));
+                               __func__, sysfs_node, rte_strerror(errno));
                ret = -1;
        }
 
@@ -323,7 +324,7 @@ dsa_scan(void)
                if (errno == ENOENT)
                        return 0; /* no bus, return without error */
                IDXD_PMD_ERR("%s(): opendir '%s' failed: %s",
-                               __func__, path, strerror(errno));
+                               __func__, path, rte_strerror(errno));
                return -1;
        }
 
-- 
2.33.0

Reply via email to