Commit 368d06f5 authored by John W. Linville's avatar John W. Linville

wireless: convert reg_regdb_search_lock to mutex

Stanse discovered that kmalloc is being called with GFP_KERNEL while
holding this spinlock.  The spinlock can be a mutex instead, which also
enables the removal of the unlock/lock around the lock/unlock of
cfg80211_mutex and the call to set_regdom.
Reported-by: default avatarJiri Slaby <jirislaby@gmail.com>
Cc: stable@kernel.org
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent c8406ea8
...@@ -324,7 +324,7 @@ struct reg_regdb_search_request { ...@@ -324,7 +324,7 @@ struct reg_regdb_search_request {
}; };
static LIST_HEAD(reg_regdb_search_list); static LIST_HEAD(reg_regdb_search_list);
static DEFINE_SPINLOCK(reg_regdb_search_lock); static DEFINE_MUTEX(reg_regdb_search_mutex);
static void reg_regdb_search(struct work_struct *work) static void reg_regdb_search(struct work_struct *work)
{ {
...@@ -332,7 +332,7 @@ static void reg_regdb_search(struct work_struct *work) ...@@ -332,7 +332,7 @@ static void reg_regdb_search(struct work_struct *work)
const struct ieee80211_regdomain *curdom, *regdom; const struct ieee80211_regdomain *curdom, *regdom;
int i, r; int i, r;
spin_lock(&reg_regdb_search_lock); mutex_lock(&reg_regdb_search_mutex);
while (!list_empty(&reg_regdb_search_list)) { while (!list_empty(&reg_regdb_search_list)) {
request = list_first_entry(&reg_regdb_search_list, request = list_first_entry(&reg_regdb_search_list,
struct reg_regdb_search_request, struct reg_regdb_search_request,
...@@ -346,18 +346,16 @@ static void reg_regdb_search(struct work_struct *work) ...@@ -346,18 +346,16 @@ static void reg_regdb_search(struct work_struct *work)
r = reg_copy_regd(&regdom, curdom); r = reg_copy_regd(&regdom, curdom);
if (r) if (r)
break; break;
spin_unlock(&reg_regdb_search_lock);
mutex_lock(&cfg80211_mutex); mutex_lock(&cfg80211_mutex);
set_regdom(regdom); set_regdom(regdom);
mutex_unlock(&cfg80211_mutex); mutex_unlock(&cfg80211_mutex);
spin_lock(&reg_regdb_search_lock);
break; break;
} }
} }
kfree(request); kfree(request);
} }
spin_unlock(&reg_regdb_search_lock); mutex_unlock(&reg_regdb_search_mutex);
} }
static DECLARE_WORK(reg_regdb_work, reg_regdb_search); static DECLARE_WORK(reg_regdb_work, reg_regdb_search);
...@@ -375,9 +373,9 @@ static void reg_regdb_query(const char *alpha2) ...@@ -375,9 +373,9 @@ static void reg_regdb_query(const char *alpha2)
memcpy(request->alpha2, alpha2, 2); memcpy(request->alpha2, alpha2, 2);
spin_lock(&reg_regdb_search_lock); mutex_lock(&reg_regdb_search_mutex);
list_add_tail(&request->list, &reg_regdb_search_list); list_add_tail(&request->list, &reg_regdb_search_list);
spin_unlock(&reg_regdb_search_lock); mutex_unlock(&reg_regdb_search_mutex);
schedule_work(&reg_regdb_work); schedule_work(&reg_regdb_work);
} }
......
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