From: Johannes Berg <johannes@sipsolutions.net>
To: John Linville <linville@tuxdriver.com>,
"David S. Miller" <davem@davemloft.net>
Cc: linux-wireless <linux-wireless@vger.kernel.org>,
netdev <netdev@vger.kernel.org>
Subject: [PATCH net-2.6.22, wireless-dev] clarify locking comment in cfg80211
Date: Tue, 24 Apr 2007 20:39:09 +0200 [thread overview]
Message-ID: <1177439950.3528.42.camel@johannes.berg> (raw)
This patch clarifies the comment about locking in wiphy_unregister.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
Diffed for wireless-dev but applies with some offset to net-2.6.22 as
well.
net/wireless/core.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
--- wireless-dev.orig/net/wireless/core.c 2007-04-24 20:21:02.648804911 +0200
+++ wireless-dev/net/wireless/core.c 2007-04-24 20:36:05.948804911 +0200
@@ -223,7 +223,6 @@ int wiphy_register(struct wiphy *wiphy)
mutex_lock(&cfg80211_drv_mutex);
-
res = device_add(&drv->wiphy.dev);
if (res)
goto out_unlock;
@@ -246,14 +245,26 @@ void wiphy_unregister(struct wiphy *wiph
{
struct cfg80211_registered_device *drv = wiphy_to_dev(wiphy);
+ /* protect the device list */
mutex_lock(&cfg80211_drv_mutex);
- /* hold registered driver mutex during list removal as well
- * to make sure no commands are in progress at the moment */
+ BUG_ON(!list_empty(&drv->netdev_list));
+
+ /*
+ * Try to grab drv->mtx. If a command is still in progress,
+ * hopefully the driver will refuse it since it's tearing
+ * down the device already. We wait for this command to complete
+ * before unlinking the item from the list.
+ * Note: as codified by the BUG_ON above we cannot get here if
+ * a virtual interface is still associated. Hence, we can only
+ * get to lock contention here if userspace issues a command
+ * that identified the hardware by wiphy index.
+ */
mutex_lock(&drv->mtx);
- list_del(&drv->list);
+ /* unlock again before freeing */
mutex_unlock(&drv->mtx);
+ list_del(&drv->list);
device_del(&drv->wiphy.dev);
debugfs_remove(drv->wiphy.debugfsdir);
reply other threads:[~2007-04-26 9:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1177439950.3528.42.camel@johannes.berg \
--to=johannes@sipsolutions.net \
--cc=davem@davemloft.net \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--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