From: Kalpesh Solanki <skalpesh942@gmail.com>
To: pkshih@realtek.com, luka.gejak@linux.dev
Cc: kvalo@kernel.org, linux-wireless@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Kalpesh Solanki <skalpesh942@gmail.com>
Subject: [PATCH v6 2/3] wifi: rtw88: skip already reset station in rtw_sta_remove()
Date: Fri, 13 Nov 2026 09:17:03 +0530 [thread overview]
Message-ID: <20261113034704.21283-3-skalpesh942@gmail.com> (raw)
In-Reply-To: <20261113034704.21283-1-skalpesh942@gmail.com>
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.
Cancel pending rate control work first, as rtw_ops_sta_rc_update() can
still schedule rc_work after the station was reset. Then check si->vif
and return early if the station was already reset. Clear si->vif,
si->mask, and si->use_cfg_mask upon removal to ensure clean teardown
and avoid a NULL pointer dereference in rtw_rate_mask_cfg() if mac80211
re-adds the station across recovery restart.
Fixes: 5c831644e1f4 ("rtw88: handle and recover when firmware crash")
Cc: stable@vger.kernel.org
Signed-off-by: Kalpesh Solanki <skalpesh942@gmail.com>
---
drivers/net/wireless/realtek/rtw88/main.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
index f7708ad17b6..8e62d38a269 100644
--- a/drivers/net/wireless/realtek/rtw88/main.c
+++ b/drivers/net/wireless/realtek/rtw88/main.c
@@ -386,6 +386,9 @@ void rtw_sta_remove(struct rtw_dev *rtwdev, struct ieee80211_sta *sta,
cancel_work_sync(&si->rc_work);
+ if (!vif)
+ return;
+
if (vif->type != NL80211_IFTYPE_STATION || sta->tdls)
rtw_release_macid(rtwdev, si->mac_id);
if (fw_exist)
@@ -395,8 +398,11 @@ 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;
+ si->use_cfg_mask = false;
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
next prev parent reply other threads:[~2026-11-13 3:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 3:47 [PATCH v6 0/3] wifi: rtw88: firmware recovery fixes and LPS hang handling Kalpesh Solanki
2026-11-13 3:47 ` [PATCH v6 1/3] wifi: rtw88: clear RTW_FLAG_RESTARTING on stop and start failure Kalpesh Solanki
2026-11-13 3:47 ` Kalpesh Solanki [this message]
2026-11-13 6:18 ` [PATCH v6 2/3] wifi: rtw88: skip already reset station in rtw_sta_remove() Luka Gejak
2026-11-13 3:47 ` [PATCH v6 3/3] wifi: rtw88: ps: trigger firmware recovery only after consecutive LPS leave failures on PCI Kalpesh Solanki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261113034704.21283-3-skalpesh942@gmail.com \
--to=skalpesh942@gmail.com \
--cc=kvalo@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=luka.gejak@linux.dev \
--cc=pkshih@realtek.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®