Internally, cfg80211_rx_mgmt() takes lock:
spin_lock_bh(&wdev->mgmt_registrations_lock);
and therefore one can't use it with GFP_KERNEL allocation flags.
When called with GFP_KERNEL, "sleep while atomic" warning triggered:
<3>[242645.446224] BUG: sleeping function called from invalid context at kernel/mm/slub.c:926
<3>[242645.455516] in_atomic(): 1, irqs_disabled(): 0, pid: 18881, name: kworker/u16:0
<6>[242645.462868] CPU: 0 PID: 18881 Comm: kworker/u16:0 Tainted: G O
3.10.40-g619a884-00001-g357fa9c #2
<6>[242645.463044] Workqueue: wil6210_wmi wmi_event_worker [wil6210]
<6>[242645.463087] Call trace:
<6>[242645.463157] [<
ffffffc000087390>] dump_backtrace+0x0/0x144
<6>[242645.463205] [<
ffffffc0000874e4>] show_stack+0x10/0x1c
<6>[242645.463259] [<
ffffffc0009abc04>] dump_stack+0x1c/0x28
<6>[242645.463313] [<
ffffffc0000c10c0>] __might_sleep+0xe0/0xf0
<6>[242645.463365] [<
ffffffc00015a514>] kmem_cache_alloc+0x48/0x1e4
<6>[242645.463414] [<
ffffffc00080d468>] __alloc_skb+0x48/0x164
<6>[242645.463466] [<
ffffffc00097f2c4>] nl80211_send_mgmt+0x4c/0x1dc
<6>[242645.463511] [<
ffffffc000980268>] cfg80211_rx_mgmt+0x1bc/0x25c
<6>[242645.463647] [<
ffffffbffc005d64>] wmi_evt_rx_mgmt+0x21c/0x23c [wil6210]
<6>[242645.463783] [<
ffffffbffc0073b8>] wmi_event_worker+0x230/0x2f8 [wil6210]
<6>[242645.463838] [<
ffffffc0000afffc>] process_one_work+0x258/0x3d0
<6>[242645.463887] [<
ffffffc0000b0fe0>] worker_thread+0x1f0/0x310
<6>[242645.463946] [<
ffffffc0000b642c>] kthread+0xac/0xb8
Signed-off-by: Vladimir Kondratiev <qca_vkondrat@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>