Commit 1b57b621 authored by Arend Van Spriel's avatar Arend Van Spriel Committed by Johannes Berg

cfg80211: make cfg80211_sched_scan_results() work from atomic context

Drivers should be able to call cfg80211_sched_scan_results() from atomic
context. However, with the introduction of multiple scheduled scan feature
this requirement was not taken into account resulting in regression shown
below.

[  119.021594] BUG: scheduling while atomic: irq/47-iwlwifi/517/0x00000200
[  119.021604] Modules linked in: [...]
[  119.021759] CPU: 1 PID: 517 Comm: irq/47-iwlwifi Not tainted 4.12.0-rc2-t440s-20170522+ #1
[  119.021763] Hardware name: LENOVO 20AQS03H00/20AQS03H00, BIOS GJET91WW (2.41 ) 09/21/2016
[  119.021766] Call Trace:
[  119.021778]  ? dump_stack+0x5c/0x84
[  119.021784]  ? __schedule_bug+0x4c/0x70
[  119.021792]  ? __schedule+0x496/0x5c0
[  119.021798]  ? schedule+0x2d/0x80
[  119.021804]  ? schedule_preempt_disabled+0x5/0x10
[  119.021810]  ? __mutex_lock.isra.0+0x18e/0x4c0
[  119.021817]  ? __wake_up+0x2f/0x50
[  119.021833]  ? cfg80211_sched_scan_results+0x19/0x60 [cfg80211]
[  119.021844]  ? cfg80211_sched_scan_results+0x19/0x60 [cfg80211]
[  119.021859]  ? iwl_mvm_rx_lmac_scan_iter_complete_notif+0x17/0x30 [iwlmvm]
[  119.021869]  ? iwl_pcie_rx_handle+0x2a9/0x7e0 [iwlwifi]
[  119.021878]  ? iwl_pcie_irq_handler+0x17c/0x730 [iwlwifi]
[  119.021884]  ? irq_forced_thread_fn+0x60/0x60
[  119.021887]  ? irq_thread_fn+0x16/0x40
[  119.021892]  ? irq_thread+0x109/0x180
[  119.021896]  ? wake_threads_waitq+0x30/0x30
[  119.021901]  ? kthread+0xf2/0x130
[  119.021905]  ? irq_thread_dtor+0x90/0x90
[  119.021910]  ? kthread_create_on_node+0x40/0x40
[  119.021915]  ? ret_from_fork+0x26/0x40

Fixes: b34939b9 ("cfg80211: add request id to cfg80211_sched_scan_*() api")
Reported-by: default avatarSander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: default avatarArend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 5667c86a
...@@ -322,9 +322,9 @@ cfg80211_find_sched_scan_req(struct cfg80211_registered_device *rdev, u64 reqid) ...@@ -322,9 +322,9 @@ cfg80211_find_sched_scan_req(struct cfg80211_registered_device *rdev, u64 reqid)
{ {
struct cfg80211_sched_scan_request *pos; struct cfg80211_sched_scan_request *pos;
ASSERT_RTNL(); WARN_ON_ONCE(!rcu_read_lock_held() && !lockdep_rtnl_is_held());
list_for_each_entry(pos, &rdev->sched_scan_req_list, list) { list_for_each_entry_rcu(pos, &rdev->sched_scan_req_list, list) {
if (pos->reqid == reqid) if (pos->reqid == reqid)
return pos; return pos;
} }
...@@ -398,13 +398,13 @@ void cfg80211_sched_scan_results(struct wiphy *wiphy, u64 reqid) ...@@ -398,13 +398,13 @@ void cfg80211_sched_scan_results(struct wiphy *wiphy, u64 reqid)
trace_cfg80211_sched_scan_results(wiphy, reqid); trace_cfg80211_sched_scan_results(wiphy, reqid);
/* ignore if we're not scanning */ /* ignore if we're not scanning */
rtnl_lock(); rcu_read_lock();
request = cfg80211_find_sched_scan_req(rdev, reqid); request = cfg80211_find_sched_scan_req(rdev, reqid);
if (request) { if (request) {
request->report_results = true; request->report_results = true;
queue_work(cfg80211_wq, &rdev->sched_scan_res_wk); queue_work(cfg80211_wq, &rdev->sched_scan_res_wk);
} }
rtnl_unlock(); rcu_read_unlock();
} }
EXPORT_SYMBOL(cfg80211_sched_scan_results); EXPORT_SYMBOL(cfg80211_sched_scan_results);
......
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