aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
diff options
context:
space:
mode:
authorFabio Aiuto <fabioaiuto83@gmail.com>2021-08-30 09:09:23 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-09-13 08:49:43 +0200
commitd1cfdcad99f0e79b46fd0e81bc1a940adbc2069d (patch)
tree8a52f515a9dc40491919f81362f7b660a368c85b /drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
parentstaging: wlan-ng: Remove filenames from files (diff)
downloadwireguard-linux-d1cfdcad99f0e79b46fd0e81bc1a940adbc2069d.tar.xz
wireguard-linux-d1cfdcad99f0e79b46fd0e81bc1a940adbc2069d.zip
staging: rtl8723bs: unwrap initialization of queues
unwrap initialization of queues to avoid false positive lockdep warning: [ 27.350258] ============================================ [ 27.350267] WARNING: possible recursive locking detected [ 27.350276] 5.14.0-rc6+ #16 Tainted: G C OE [ 27.350288] -------------------------------------------- [ 27.350295] RTW_CMD_THREAD/679 is trying to acquire lock: [ 27.350306] ffffa846c03290c8 (&(pqueue->lock)){+.-.}-{2:2}, at: rtw_alloc_network+0x1b/0xa0 [r8723bs] [ 27.350441] but task is already holding lock: [ 27.350448] ffffa846c0329118 (&(pqueue->lock)){+.-.}-{2:2}, at: rtw_update_scanned_network+0x33/0x1d0 [r8723bs] [ 27.350573] other info that might help us debug this: [ 27.350581] Possible unsafe locking scenario: [ 27.350588] CPU0 [ 27.350594] ---- [ 27.350600] lock(&(pqueue->lock)); [ 27.350614] lock(&(pqueue->lock)); [ 27.350627] *** DEADLOCK *** [ 27.350634] May be due to missing lock nesting notation [ 27.350641] 2 locks held by RTW_CMD_THREAD/679: [ 27.350652] #0: ffffa846c0329038 (&pmlmepriv->lock){+...}-{2:2}, at: rtw_survey_event_callback+0x2d/0xe0 [r8723bs] [ 27.350780] #1: ffffa846c0329118 (&(pqueue->lock)){+.-.}-{2:2}, at: rtw_update_scanned_network+0x33/0x1d0 [r8723bs] [ 27.350907] stack backtrace: [ 27.350916] CPU: 3 PID: 679 Comm: RTW_CMD_THREAD Tainted: G C OE 5.14.0-rc6+ #16 [ 27.350933] Hardware name: LENOVO 80NR/Madrid, BIOS DACN25WW 08/20/2015 [ 27.350943] Call Trace: [ 27.350959] dump_stack_lvl+0x56/0x6f [ 27.350982] __lock_acquire.cold.79+0x137/0x298 [ 27.351012] lock_acquire+0xb4/0x2c0 [ 27.351031] ? rtw_alloc_network+0x1b/0xa0 [r8723bs] [ 27.351140] ? rtw_update_scanned_network+0x33/0x1d0 [r8723bs] [ 27.351254] _raw_spin_lock_bh+0x34/0x40 [ 27.351271] ? rtw_alloc_network+0x1b/0xa0 [r8723bs] [ 27.351378] rtw_alloc_network+0x1b/0xa0 [r8723bs] [ 27.351488] rtw_update_scanned_network+0xa5/0x1d0 [r8723bs] [ 27.351605] rtw_survey_event_callback+0x54/0xe0 [r8723bs] [ 27.351719] mlme_evt_hdl+0x4e/0x70 [r8723bs] [ 27.351839] rtw_cmd_thread+0x16c/0x3d0 [r8723bs] [ 27.351945] ? rtw_stop_cmd_thread+0x50/0x50 [r8723bs] [ 27.352045] kthread+0x136/0x160 [ 27.352064] ? set_kthread_struct+0x40/0x40 [ 27.352083] ret_from_fork+0x22/0x30 This happens because the wrapping function _rtw_init_queues() bring lockdep considering all queues as a single one. But all queues are different with their own lock. Applied the following semantic patch: @@ expression a; @@ - _rtw_init_queue(&a); + INIT_LIST_HEAD(&a.queue); + spin_lock_init(&a.lock); Reported-by: Hans De Goede <hdegoede@redhat.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Fabio Aiuto <fabioaiuto83@gmail.com> Link: https://lore.kernel.org/r/c2c3a18cc2b883feab74f150ccbaa4f2cc11995c.1630307025.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/rtl8723bs/core/rtw_sta_mgt.c')
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_sta_mgt.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
index 67ca219f95bf..bf090f3b1db6 100644
--- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
@@ -19,7 +19,8 @@ void _rtw_init_stainfo(struct sta_info *psta)
/* INIT_LIST_HEAD(&psta->sleep_list); */
/* INIT_LIST_HEAD(&psta->wakeup_list); */
- _rtw_init_queue(&psta->sleep_q);
+ INIT_LIST_HEAD(&psta->sleep_q.queue);
+ spin_lock_init(&psta->sleep_q.lock);
psta->sleepq_len = 0;
_rtw_init_sta_xmit_priv(&psta->sta_xmitpriv);
@@ -62,14 +63,17 @@ u32 _rtw_init_sta_priv(struct sta_priv *pstapriv)
pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 -
((SIZE_PTR)(pstapriv->pallocated_stainfo_buf) & 3);
- _rtw_init_queue(&pstapriv->free_sta_queue);
+ INIT_LIST_HEAD(&pstapriv->free_sta_queue.queue);
+ spin_lock_init(&pstapriv->free_sta_queue.lock);
spin_lock_init(&pstapriv->sta_hash_lock);
/* _rtw_init_queue(&pstapriv->asoc_q); */
pstapriv->asoc_sta_count = 0;
- _rtw_init_queue(&pstapriv->sleep_q);
- _rtw_init_queue(&pstapriv->wakeup_q);
+ INIT_LIST_HEAD(&pstapriv->sleep_q.queue);
+ spin_lock_init(&pstapriv->sleep_q.lock);
+ INIT_LIST_HEAD(&pstapriv->wakeup_q.queue);
+ spin_lock_init(&pstapriv->wakeup_q.lock);
psta = (struct sta_info *)(pstapriv->pstainfo_buf);
@@ -242,7 +246,8 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
/* preorder_ctrl->wsize_b = (NR_RECVBUFF-2); */
preorder_ctrl->wsize_b = 64;/* 64; */
- _rtw_init_queue(&preorder_ctrl->pending_recvframe_queue);
+ INIT_LIST_HEAD(&preorder_ctrl->pending_recvframe_queue.queue);
+ spin_lock_init(&preorder_ctrl->pending_recvframe_queue.lock);
rtw_init_recv_timer(preorder_ctrl);
}