public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [BUG] staging: wfx: possible deadlock in wfx_conf_tx() and wfx_add_interface()
@ 2022-02-01  7:09 Jia-Ju Bai
       [not found] ` <20220201113303.3883-1-hdanton@sina.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Jia-Ju Bai @ 2022-02-01  7:09 UTC (permalink / raw)
  To: jerome.pouiller, Greg KH; +Cc: linux-staging, linux-kernel

Hello,

My static analysis tool reports a possible deadlock in the wfx driver in 
Linux 5.16:

wfx_conf_tx()
   mutex_lock(&wdev->conf_mutex); --> Line 225 (Lock A)
   wfx_update_pm()
     wait_for_completion_timeout(&wvif->set_pm_mode_complete, ...); --> 
Line 3019 (Wait X)

wfx_add_interface()
   mutex_lock(&wdev->conf_mutex); --> Line 737 (Lock A)
   complete(&wvif->set_pm_mode_complete); --> Line 758 (Wake X)

When wfx_conf_tx() is executed, "Wait X" is performed by holding "Lock 
A". If wfx_add_interface() is executed at this time, "Wake X" cannot be 
performed to wake up "Wait X" in wfx_conf_tx(), because "Lock A" has 
been already hold by wfx_conf_tx(), causing a possible deadlock.
I find that "Wait X" is performed with a timeout, to relieve the 
possible deadlock; but I think this timeout can cause inefficient execution.

I am not quite sure whether this possible problem is real and how to fix 
it if it is real.
Any feedback would be appreciated, thanks :)


Best wishes,
Jia-Ju Bai


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

end of thread, other threads:[~2022-02-05  8:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-01  7:09 [BUG] staging: wfx: possible deadlock in wfx_conf_tx() and wfx_add_interface() Jia-Ju Bai
     [not found] ` <20220201113303.3883-1-hdanton@sina.com>
2022-02-01 11:56   ` Jérôme Pouiller
2022-02-05  8:34   ` Jia-Ju Bai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox