patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH v3] app/testpmd: fix heap-free-before-use when quit
@ 2022-03-02  7:08 wenxuanx.wu
  0 siblings, 0 replies; 12+ messages in thread
From: wenxuanx.wu @ 2022-03-02  7:08 UTC (permalink / raw)
  To: build_sh; +Cc: wenxuan wu, stable

From: wenxuan wu <wenxuanx.wu@intel.com>

Change func logic is_bonding_slave and set_port_slave_flag to avoid this
error.Port->slave_flag with dev_flag check to ensure slave_flag is securely
set.

Remove eth_dev_info_get in func is_bonding_slave, which would lead to
a heap-free-before-use error the reason is that vf was still accessing a
freed pf resource.

Fixes: 0a0821bcf312 ("app/testpmd: remove most uses of internal ethdev array")
Cc: stable@dpdk.org

Signed-off-by: Wenxuan Wu <wenxuanx.wu@intel.com>
---
 app/test-pmd/testpmd.c | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index e1da961311..dcba11f7a6 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3805,15 +3805,23 @@ init_port_config(void)
 	}
 }
 
-void set_port_slave_flag(portid_t slave_pid)
+void
+set_port_slave_flag(portid_t slave_pid)
 {
 	struct rte_port *port;
-
+	struct rte_eth_dev_info dev_info;
+	int ret;
 	port = &ports[slave_pid];
-	port->slave_flag = 1;
+	ret = eth_dev_info_get_print_err(slave_pid, &dev_info);
+	if (ret != 0)
+		return;
+
+	if (*dev_info.dev_flags & RTE_ETH_DEV_BONDED_SLAVE)
+		port->slave_flag = 1;
 }
 
-void clear_port_slave_flag(portid_t slave_pid)
+void
+clear_port_slave_flag(portid_t slave_pid)
 {
 	struct rte_port *port;
 
@@ -3821,26 +3829,17 @@ void clear_port_slave_flag(portid_t slave_pid)
 	port->slave_flag = 0;
 }
 
-uint8_t port_is_bonding_slave(portid_t slave_pid)
+uint8_t
+port_is_bonding_slave(portid_t slave_pid)
 {
 	struct rte_port *port;
-	struct rte_eth_dev_info dev_info;
-	int ret;
-
 	port = &ports[slave_pid];
-	ret = eth_dev_info_get_print_err(slave_pid, &dev_info);
-	if (ret != 0) {
-		TESTPMD_LOG(ERR,
-			"Failed to get device info for port id %d,"
-			"cannot determine if the port is a bonded slave",
-			slave_pid);
-		return 0;
-	}
-	if ((*dev_info.dev_flags & RTE_ETH_DEV_BONDED_SLAVE) || (port->slave_flag == 1))
+	if (port->slave_flag == 1)
 		return 1;
 	return 0;
 }
 
+
 const uint16_t vlan_tags[] = {
 		0,  1,  2,  3,  4,  5,  6,  7,
 		8,  9, 10, 11,  12, 13, 14, 15,
-- 
2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-03-10  7:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <de87ae03-a26a-a9d3-da70-424335777371@intel.com>
     [not found] ` <20220223113251.723692-1-wenxuanx.wu@intel.com>
2022-02-23 11:32   ` [PATCH v2 1/2] lib/ethdev: add reverse macro to quit testpmd wenxuanx.wu
2022-02-23 11:32   ` [PATCH v2 2/2] app/testpmd:fix testpmd quit failure wenxuanx.wu
2022-02-23 12:09     ` Ferruh Yigit
2022-03-01  7:28     ` [PATCH v3] app/testpmd: fix heap-free-before-use when quit wenxuanx.wu
2022-03-02  7:20     ` wenxuanx.wu
2022-03-02  8:06     ` wenxuanx.wu
2022-03-02  8:34     ` wenxuanx.wu
2022-03-03 13:22     ` [PATCH v2 2/2] app/testpmd:fix testpmd quit failure Wu, WenxuanX
2022-03-04 16:15       ` Ferruh Yigit
2022-03-09  3:07         ` Wu, WenxuanX
2022-03-10  7:02           ` Wu, WenxuanX
2022-03-02  7:08 [PATCH v3] app/testpmd: fix heap-free-before-use when quit wenxuanx.wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).