Commit 4a484cff authored by Johannes Berg's avatar Johannes Berg

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: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent c51f8783
...@@ -140,7 +140,7 @@ static void rcu_free_regdom(const struct ieee80211_regdomain *r) ...@@ -140,7 +140,7 @@ static void rcu_free_regdom(const struct ieee80211_regdomain *r)
static struct regulatory_request *get_last_request(void) static struct regulatory_request *get_last_request(void)
{ {
return rcu_dereference_protected(last_request, return rcu_dereference_check(last_request,
lockdep_is_held(&reg_mutex)); lockdep_is_held(&reg_mutex));
} }
...@@ -2250,14 +2250,21 @@ int set_regdom(const struct ieee80211_regdomain *rd) ...@@ -2250,14 +2250,21 @@ int set_regdom(const struct ieee80211_regdomain *rd)
#ifdef CONFIG_HOTPLUG #ifdef CONFIG_HOTPLUG
int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env) int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env)
{ {
struct regulatory_request *lr = get_last_request(); struct regulatory_request *lr;
u8 alpha2[2];
bool add = false;
rcu_read_lock();
lr = get_last_request();
if (lr && !lr->processed) { if (lr && !lr->processed) {
if (add_uevent_var(env, "COUNTRY=%c%c", memcpy(alpha2, lr->alpha2, 2);
lr->alpha2[0], lr->alpha2[1])) add = true;
return -ENOMEM;
} }
rcu_read_unlock();
if (add)
return add_uevent_var(env, "COUNTRY=%c%c",
alpha2[0], alpha2[1]);
return 0; return 0;
} }
#else #else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment