aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/reg.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2013-01-09 04:22:07 -0500
committerJohannes Berg <johannes.berg@intel.com>2013-01-09 06:19:43 -0500
commit4a484cffc5e1836114e9556f7c704412d491200c (patch)
treedb228d48bc1c0b8244892d2a329b514da167f339 /net/wireless/reg.c
parentc51f878379b1d0677619798b1d9358d053bdbdb1 (diff)
regulatory: fix uevent
The uevent callback doesn't protect its access to last_request, which now causes a warning since the conversion to get_last_request(). Fix this by allowing to use RCU protection for last_request. Reported-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless/reg.c')
-rw-r--r--net/wireless/reg.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 0b35de001937..2193f62bb8ae 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -140,8 +140,8 @@ static void rcu_free_regdom(const struct ieee80211_regdomain *r)
140 140
141static struct regulatory_request *get_last_request(void) 141static struct regulatory_request *get_last_request(void)
142{ 142{
143 return rcu_dereference_protected(last_request, 143 return rcu_dereference_check(last_request,
144 lockdep_is_held(&reg_mutex)); 144 lockdep_is_held(&reg_mutex));
145} 145}
146 146
147/* Used to queue up regulatory hints */ 147/* Used to queue up regulatory hints */
@@ -2250,14 +2250,21 @@ int set_regdom(const struct ieee80211_regdomain *rd)
2250#ifdef CONFIG_HOTPLUG 2250#ifdef CONFIG_HOTPLUG
2251int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env) 2251int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env)
2252{ 2252{
2253 struct regulatory_request *lr = get_last_request(); 2253 struct regulatory_request *lr;
2254 u8 alpha2[2];
2255 bool add = false;
2254 2256
2257 rcu_read_lock();
2258 lr = get_last_request();
2255 if (lr && !lr->processed) { 2259 if (lr && !lr->processed) {
2256 if (add_uevent_var(env, "COUNTRY=%c%c", 2260 memcpy(alpha2, lr->alpha2, 2);
2257 lr->alpha2[0], lr->alpha2[1])) 2261 add = true;
2258 return -ENOMEM;
2259 } 2262 }
2263 rcu_read_unlock();
2260 2264
2265 if (add)
2266 return add_uevent_var(env, "COUNTRY=%c%c",
2267 alpha2[0], alpha2[1]);
2261 return 0; 2268 return 0;
2262} 2269}
2263#else 2270#else