From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] net/kni: fix crash caused by double stop
Date: Tue, 26 Nov 2019 10:50:07 +0000 [thread overview]
Message-ID: <20191126105007.62289-1-ferruh.yigit@intel.com> (raw)
'close()' calls 'stop()' and 'stop()' cancels pthread without any check.
Calling 'stop()' & 'close()' sequentially tries to cancel pthread twice
which will cause a crash.
Adding a state check in 'stop()' before canceling the pthread to prevent
multiple stop.
Fixes: 696fbc7bb4fc ("net/kni: remove resources when port is closed")
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
drivers/net/kni/rte_eth_kni.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
index 7cba92e2e..d88cb1778 100644
--- a/drivers/net/kni/rte_eth_kni.c
+++ b/drivers/net/kni/rte_eth_kni.c
@@ -156,6 +156,8 @@ eth_kni_dev_start(struct rte_eth_dev *dev)
}
if (internals->no_request_thread == 0) {
+ internals->stop_thread = 0;
+
ret = rte_ctrl_thread_create(&internals->thread,
"kni_handle_req", NULL,
kni_handle_request, internals);
@@ -177,7 +179,7 @@ eth_kni_dev_stop(struct rte_eth_dev *dev)
struct pmd_internals *internals = dev->data->dev_private;
int ret;
- if (internals->no_request_thread == 0) {
+ if (internals->no_request_thread == 0 && internals->stop_thread == 0) {
internals->stop_thread = 1;
ret = pthread_cancel(internals->thread);
@@ -187,8 +189,6 @@ eth_kni_dev_stop(struct rte_eth_dev *dev)
ret = pthread_join(internals->thread, NULL);
if (ret)
PMD_LOG(ERR, "Can't join the thread");
-
- internals->stop_thread = 0;
}
dev->data->dev_link.link_status = 0;
--
2.21.0
next reply other threads:[~2019-11-26 10:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-26 10:50 Ferruh Yigit [this message]
2019-11-26 14:46 ` Ferruh Yigit
2019-11-26 15:42 ` Wang, Yinan
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=20191126105007.62289-1-ferruh.yigit@intel.com \
--to=ferruh.yigit@intel.com \
--cc=dev@dpdk.org \
/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).