netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jia-Ju Bai <baijiaju1990@gmail.com>
To: chunkeey@googlemail.com, kvalo@kernel.org, davem@davemloft.net,
	kuba@kernel.org
Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [BUG] intersil: p54: possible deadlock in p54_remove_interface() and p54_stop()
Date: Mon, 7 Feb 2022 23:31:26 +0800	[thread overview]
Message-ID: <fb543659-f69d-242f-b18a-69dd8b8b5ca1@gmail.com> (raw)

Hello,

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

p54_remove_interface()
   mutex_lock(&priv->conf_mutex); --> Line 262 (Lock A)
wait_for_completion_interruptible_timeout(&priv->beacon_comp, HZ); --> 
Line 271 (Wait X)

p54_stop()
   mutex_lock(&priv->conf_mutex); --> Line 208 (Lock A)
   p54p_stop() (call via priv->stop)
     p54_free_skb()
       p54_tx_qos_accounting_free()
         complete(&priv->beacon_comp); --> Line 230 (Wake X)

When p54_remove_interface() is executed, "Wait X" is performed by 
holding "Lock A". If p54_stop() is executed at this time, "Wake X" 
cannot be performed to wake up "Wait X" in p54_remove_interface(), 
because "Lock A" has been already hold by p54_remove_interface(), 
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

             reply	other threads:[~2022-02-07 15:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-07 15:31 Jia-Ju Bai [this message]
2022-02-07 21:13 ` [BUG] intersil: p54: possible deadlock in p54_remove_interface() and p54_stop() Christian Lamparter

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=fb543659-f69d-242f-b18a-69dd8b8b5ca1@gmail.com \
    --to=baijiaju1990@gmail.com \
    --cc=chunkeey@googlemail.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.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).