net/kni: fix crash caused by double stop
PATCH 1/1 net/kni: fix crash caused by double stop
'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.
--- drivers/net/kni/rte_eth_kni.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/kni/rte_eth_kni.c +3 -3
@@ -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 ;
Signature · 1 line
2.21.0
Ferruh Yigit
AppliedQuoted 10 lines · Ferruh Yigit
'
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 <[email protected]>
Applied to dpdk-next-net/master, thanks.
(Applied quickly to make the fix for rc4)
Quoted 22 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Ferruh Yigit
Sent: 2019年11月26日 22:47
To: Yigit, Ferruh <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH] net/kni: fix crash caused by double stopQuoted 10 lines · Ferruh Yigit
'
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 <[email protected]>Applied to dpdk-next-net/master, thanks.
(Applied quickly to make the fix for rc4)