[PATCH v4 2/3] wifi: rtw88: skip already reset station in rtw_sta_remove()
From: Kalpesh Solanki
Date: Sun Nov 08 2026 - 09:30:43 EST
During firmware recovery, __fw_recovery_work() iterates over all
stations and invokes rtw_sta_remove() via rtw_reset_sta_iter().
If recovery is triggered concurrently with station teardown (such as
during ieee80211_set_disassoc() where mac80211 leaves LPS before
removing the AP station), rtw_ops_sta_remove() is subsequently called
for the same station. This causes rtw_sta_remove() to execute twice,
leading to a double free of si->mask and an underflow of rtwdev->sta_cnt.
Check si->vif in rtw_sta_remove() and return early if the station was
already reset, setting si->vif and si->mask to NULL upon removal.
Fixes: 5c831644e1f4 ("rtw88: handle and recover when firmware crash")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Kalpesh Solanki <skalpesh942@xxxxxxxxx>
---
drivers/net/wireless/realtek/rtw88/main.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
index f7708ad17b6..a74f199a93a 100644
--- a/drivers/net/wireless/realtek/rtw88/main.c
+++ b/drivers/net/wireless/realtek/rtw88/main.c
@@ -384,6 +384,9 @@ void rtw_sta_remove(struct rtw_dev *rtwdev, struct ieee80211_sta *sta,
struct ieee80211_vif *vif = si->vif;
int i;
+ if (!vif)
+ return;
+
cancel_work_sync(&si->rc_work);
if (vif->type != NL80211_IFTYPE_STATION || sta->tdls)
@@ -395,8 +398,10 @@ void rtw_sta_remove(struct rtw_dev *rtwdev, struct ieee80211_sta *sta,
rtw_txq_cleanup(rtwdev, sta->txq[i]);
kfree(si->mask);
+ si->mask = NULL;
rtwdev->sta_cnt--;
+ si->vif = NULL;
rtw_dbg(rtwdev, RTW_DBG_STATE, "sta %pM with macid %d left\n",
sta->addr, si->mac_id);
}
--
2.53.0