From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 5E15B43329;
	Tue, 14 Nov 2023 13:38:21 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 5854F40ED2;
	Tue, 14 Nov 2023 13:36:23 +0100 (CET)
Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187])
 by mails.dpdk.org (Postfix) with ESMTP id BBE7B402B0
 for <dev@dpdk.org>; Tue, 14 Nov 2023 13:35:57 +0100 (CET)
Received: from dggpeml500011.china.huawei.com (unknown [172.30.72.56])
 by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SV5Kd3mF7zmXGm;
 Tue, 14 Nov 2023 20:32:37 +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:56 +0800
From: Dengdui Huang <huangdengdui@huawei.com>
To: <dev@dpdk.org>
CC: <ferruh.yigit@amd.com>, <stephen@networkplumber.org>,
 <lihuisong@huawei.com>, <fengchengwen@huawei.com>, <liuyonglong@huawei.com>
Subject: [PATCH v3 23/42] net/bonding: use rte strerror
Date: Tue, 14 Nov 2023 20:35:33 +0800
Message-ID: <20231114123552.398072-24-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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=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 <huangdengdui@huawei.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
 drivers/net/bonding/bonding_testpmd.c   | 4 ++--
 drivers/net/bonding/rte_eth_bond_api.c  | 2 +-
 drivers/net/bonding/rte_eth_bond_flow.c | 4 ++--
 drivers/net/bonding/rte_eth_bond_pmd.c  | 6 +++---
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/bonding/bonding_testpmd.c b/drivers/net/bonding/bonding_testpmd.c
index 8fcd6cadd0..111f9de0e7 100644
--- a/drivers/net/bonding/bonding_testpmd.c
+++ b/drivers/net/bonding/bonding_testpmd.c
@@ -551,7 +551,7 @@ static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
 	/* check the return value and print it if is < 0 */
 	if (ret < 0)
 		fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
-			strerror(-ret));
+			rte_strerror(-ret));
 }
 
 static cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
@@ -604,7 +604,7 @@ static void cmd_set_bond_mon_period_parsed(void *parsed_result,
 	/* check the return value and print it if is < 0 */
 	if (ret < 0)
 		fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
-			strerror(-ret));
+			rte_strerror(-ret));
 }
 
 static cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 99e496556a..1d20d421bc 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -483,7 +483,7 @@ __eth_bond_member_add_lock_free(uint16_t bonding_port_id, uint16_t member_port_i
 	if (ret != 0) {
 		RTE_BOND_LOG(ERR,
 			"%s: Error during getting device (port %u) info: %s\n",
-			__func__, member_port_id, strerror(-ret));
+			__func__, member_port_id, rte_strerror(-ret));
 
 		return ret;
 	}
diff --git a/drivers/net/bonding/rte_eth_bond_flow.c b/drivers/net/bonding/rte_eth_bond_flow.c
index 71a91675f7..b7e966f393 100644
--- a/drivers/net/bonding/rte_eth_bond_flow.c
+++ b/drivers/net/bonding/rte_eth_bond_flow.c
@@ -31,7 +31,7 @@ bond_flow_alloc(int numa_node, const struct rte_flow_attr *attr,
 	if (ret < 0) {
 		RTE_BOND_LOG(ERR, "Unable to process flow rule (%s): %s",
 			     error.message ? error.message : "unspecified",
-			     strerror(rte_errno));
+			     rte_strerror(rte_errno));
 		return NULL;
 	}
 	flow = rte_zmalloc_socket(NULL, offsetof(struct rte_flow, rule) + ret,
@@ -45,7 +45,7 @@ bond_flow_alloc(int numa_node, const struct rte_flow_attr *attr,
 	if (ret < 0) {
 		RTE_BOND_LOG(ERR, "Failed to copy flow rule (%s): %s",
 			     error.message ? error.message : "unspecified",
-			     strerror(rte_errno));
+			     rte_strerror(rte_errno));
 		rte_free(flow);
 		return NULL;
 	}
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index c40d18d128..fdf152a51a 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -192,7 +192,7 @@ bond_ethdev_8023ad_flow_verify(struct rte_eth_dev *bond_dev,
 	if (ret != 0) {
 		RTE_BOND_LOG(ERR,
 			"%s: Error during getting device (port %u) info: %s\n",
-			__func__, member_port, strerror(-ret));
+			__func__, member_port, rte_strerror(-ret));
 
 		return ret;
 	}
@@ -223,7 +223,7 @@ bond_8023ad_slow_pkt_hw_filter_supported(uint16_t port_id) {
 			RTE_BOND_LOG(ERR,
 				"%s: Error during getting device (port %u) info: %s\n",
 				__func__, bond_dev->data->port_id,
-				strerror(-ret));
+				rte_strerror(-ret));
 
 			return ret;
 		}
@@ -2292,7 +2292,7 @@ bond_ethdev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 					"%s: Error during getting device (port %u) info: %s\n",
 					__func__,
 					member.port_id,
-					strerror(-ret));
+					rte_strerror(-ret));
 
 				return ret;
 			}
-- 
2.33.0