DPDK patches and discussions
 help / color / Atom feed
* [dpdk-dev] [PATCH] net/kni: fix crash caused by double stop
@ 2019-11-26 10:50 Ferruh Yigit
  2019-11-26 14:46 ` Ferruh Yigit
  0 siblings, 1 reply; 3+ messages in thread
From: Ferruh Yigit @ 2019-11-26 10:50 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev

'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


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

* Re: [dpdk-dev] [PATCH] net/kni: fix crash caused by double stop
  2019-11-26 10:50 [dpdk-dev] [PATCH] net/kni: fix crash caused by double stop Ferruh Yigit
@ 2019-11-26 14:46 ` Ferruh Yigit
  2019-11-26 15:42   ` Wang, Yinan
  0 siblings, 1 reply; 3+ messages in thread
From: Ferruh Yigit @ 2019-11-26 14:46 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev

On 11/26/2019 10:50 AM, Ferruh Yigit wrote:
> '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>

Applied to dpdk-next-net/master, thanks.

(Applied quickly to make the fix for rc4)


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

* Re: [dpdk-dev] [PATCH] net/kni: fix crash caused by double stop
  2019-11-26 14:46 ` Ferruh Yigit
@ 2019-11-26 15:42   ` Wang, Yinan
  0 siblings, 0 replies; 3+ messages in thread
From: Wang, Yinan @ 2019-11-26 15:42 UTC (permalink / raw)
  To: Yigit, Ferruh, Yigit, Ferruh; +Cc: dev

Test-by :Wang, Yinan <yinan.wang@intel.com>

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Ferruh Yigit
> Sent: 2019年11月26日 22:47
> To: Yigit, Ferruh <ferruh.yigit@intel.com>
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] net/kni: fix crash caused by double stop
> 
> On 11/26/2019 10:50 AM, Ferruh Yigit wrote:
> > '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>
> 
> Applied to dpdk-next-net/master, thanks.
> 
> (Applied quickly to make the fix for rc4)


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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-26 10:50 [dpdk-dev] [PATCH] net/kni: fix crash caused by double stop Ferruh Yigit
2019-11-26 14:46 ` Ferruh Yigit
2019-11-26 15:42   ` Wang, Yinan

DPDK patches and discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox