From: wenxuanx.wu@intel.com
To: aman.deep.singh@intel.com, yuying.zhang@intel.com, xiaoyun.li@intel.com
Cc: dpdk@stable.org, wenxuan wu <wenxuanx.wu@intel.com>, stable@dpdk.org
Subject: [PATCH v3] app/testpmd: fix heap-free-before-use when quit
Date: Wed, 2 Mar 2022 15:20:48 +0800 [thread overview]
Message-ID: <20220302072048.242482-1-wenxuanx.wu@intel.com> (raw)
In-Reply-To: <20220223113251.723692-3-wenxuanx.wu@intel.com>
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
next prev parent reply other threads:[~2022-03-02 7:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220302072048.242482-1-wenxuanx.wu@intel.com \
--to=wenxuanx.wu@intel.com \
--cc=aman.deep.singh@intel.com \
--cc=dpdk@stable.org \
--cc=stable@dpdk.org \
--cc=xiaoyun.li@intel.com \
--cc=yuying.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).