summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinu Jin <s9430939@naver.com>2026-01-31 20:11:53 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-02-07 16:10:04 +0300
commit02df7c635bd3463abcd92414e32a2cb906089e72 (patch)
tree71c88838e290f009de94faf5867963a9d5fa68f2
parent8ae0398e70d9d64309708471cf7747097a5f755e (diff)
downloadlinux-02df7c635bd3463abcd92414e32a2cb906089e72.tar.xz
staging: rtl8723bs: fix potential race in expire_timeout_chk
The expire_timeout_chk function currently do lock and unlock inside the loop before calling rtw_free_stainfo(). This can be risky as the list might be changed when the lock is briefly released. To fix this, move expired sta_info entries into a local free_list while holding the lock, and then perform the actual freeing after the lock is released. Signed-off-by: Minu Jin <s9430939@naver.com> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://patch.msgid.link/20260131171153.3729458-1-s9430939@naver.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_ap.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c
index 477fe238add4..2900ff476fc1 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -178,6 +178,8 @@ void expire_timeout_chk(struct adapter *padapter)
struct sta_priv *pstapriv = &padapter->stapriv;
u8 chk_alive_num = 0;
char chk_alive_list[NUM_STA];
+ struct sta_info *psta_tmp;
+ LIST_HEAD(free_list);
int i;
spin_lock_bh(&pstapriv->auth_list_lock);
@@ -190,19 +192,19 @@ void expire_timeout_chk(struct adapter *padapter)
if (psta->expire_to > 0) {
psta->expire_to--;
if (psta->expire_to == 0) {
- list_del_init(&psta->auth_list);
+ list_move(&psta->auth_list, &free_list);
pstapriv->auth_list_cnt--;
-
- spin_unlock_bh(&pstapriv->auth_list_lock);
-
- rtw_free_stainfo(padapter, psta);
-
- spin_lock_bh(&pstapriv->auth_list_lock);
}
}
}
spin_unlock_bh(&pstapriv->auth_list_lock);
+
+ list_for_each_entry_safe(psta, psta_tmp, &free_list, auth_list) {
+ list_del_init(&psta->auth_list);
+ rtw_free_stainfo(padapter, psta);
+ }
+
psta = NULL;
spin_lock_bh(&pstapriv->asoc_list_lock);