From: Johannes Berg <johannes@sipsolutions.net>
To: linux-wireless@vger.kernel.org
Cc: Johannes Berg <johannes.berg@intel.com>
Subject: [PATCH 6/9] regulatory: use RCU in regulatory_hint_11d()
Date: Thu, 16 May 2013 23:03:35 +0200 [thread overview]
Message-ID: <1368738218-7597-7-git-send-email-johannes@sipsolutions.net> (raw)
In-Reply-To: <1368738218-7597-1-git-send-email-johannes@sipsolutions.net>
From: Johannes Berg <johannes.berg@intel.com>
Since it just does a quick check of the last regulatory
request, the function doesn't have to hold the reg mutex
but can use RCU instead.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
net/wireless/reg.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 5ceadbb..a06412fb 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1725,20 +1725,18 @@ void regulatory_hint_11d(struct wiphy *wiphy, enum ieee80211_band band,
{
char alpha2[2];
enum environment_cap env = ENVIRON_ANY;
- struct regulatory_request *request, *lr;
-
- mutex_lock(®_mutex);
- lr = get_last_request();
-
- if (unlikely(!lr))
- goto out;
+ struct regulatory_request *request = NULL, *lr;
/* IE len must be evenly divisible by 2 */
if (country_ie_len & 0x01)
- goto out;
+ return;
if (country_ie_len < IEEE80211_COUNTRY_IE_MIN_LEN)
- goto out;
+ return;
+
+ request = kzalloc(sizeof(*request), GFP_KERNEL);
+ if (!request)
+ return;
alpha2[0] = country_ie[0];
alpha2[1] = country_ie[1];
@@ -1748,6 +1746,12 @@ void regulatory_hint_11d(struct wiphy *wiphy, enum ieee80211_band band,
else if (country_ie[2] == 'O')
env = ENVIRON_OUTDOOR;
+ rcu_read_lock();
+ lr = get_last_request();
+
+ if (unlikely(!lr))
+ goto out;
+
/*
* We will run this only upon a successful connection on cfg80211.
* We leave conflict resolution to the workqueue, where can hold
@@ -1757,10 +1761,6 @@ void regulatory_hint_11d(struct wiphy *wiphy, enum ieee80211_band band,
lr->wiphy_idx != WIPHY_IDX_INVALID)
goto out;
- request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL);
- if (!request)
- goto out;
-
request->wiphy_idx = get_wiphy_idx(wiphy);
request->alpha2[0] = alpha2[0];
request->alpha2[1] = alpha2[1];
@@ -1768,8 +1768,10 @@ void regulatory_hint_11d(struct wiphy *wiphy, enum ieee80211_band band,
request->country_ie_env = env;
queue_regulatory_request(request);
+ request = NULL;
out:
- mutex_unlock(®_mutex);
+ kfree(request);
+ rcu_read_unlock();
}
static void restore_alpha2(char *alpha2, bool reset_user)
--
1.8.0
next prev parent reply other threads:[~2013-05-16 21:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-16 21:03 [PATCH 0/9] cfg80211 spring cleaning Johannes Berg
2013-05-16 21:03 ` [PATCH 1/9] cfg80211: move cfg80211_get_dev_from_ifindex under wext Johannes Berg
2013-05-16 21:03 ` [PATCH 2/9] cfg80211: use atomic_t for wiphy counter Johannes Berg
2013-05-16 21:03 ` [PATCH 3/9] cfg80211: vastly simplify locking Johannes Berg
2013-05-16 21:03 ` [PATCH 4/9] cfg80211/mac80211: use cfg80211 wdev mutex in mac80211 Johannes Berg
2013-05-16 21:03 ` [PATCH 5/9] cfg80211: simplify and correct P2P-Device scan check Johannes Berg
2013-05-16 21:03 ` Johannes Berg [this message]
2013-05-16 21:03 ` [PATCH 7/9] regulatory: remove reg_mutex Johannes Berg
2013-05-16 21:03 ` [PATCH 8/9] cfg80211: remove some locked wrappers from mlme API Johannes Berg
2013-05-16 21:03 ` [PATCH 9/9] cfg80211: remove some locked wrappers from sme API Johannes Berg
2013-05-24 22:01 ` [PATCH 0/9] cfg80211 spring cleaning Johannes Berg
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=1368738218-7597-7-git-send-email-johannes@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=johannes.berg@intel.com \
--cc=linux-wireless@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