Skip to contentSkip to conversation

wifi: mt76: mt7996: restore the wcid flags on reassociation

PATCH New Zhao Li 1 participant 1 message Nov 18

Subsystems (3)
lore
Share & tools
lore

Zhao Li

author
#0 lore raw

PATCH 1/1 wifi: mt76: mt7996: restore the wcid flags on reassociation

On disassociation, mt7996_mac_sta_links_event() clears wcid.sta and sets wcid.sta_disabled. Nothing has cleared wcid.sta_disabled on reassociation since commit 13e2e9c6b348 ("wifi: mt76: mt7996: use mac80211 .sta_state op") started setting it. The ASSOC event used to set wcid.sta again only after the rate control commands, and no longer sets it at all, so wcid_to_sta() returns NULL for a reassociated station, and both mt7996_mcu_add_rate_ctrl() and mt7996_mcu_add_rate_ctrl_fixed() dereference it.

Set wcid.sta and clear wcid.sta_disabled at the start of the ASSOC event, as for a first association.

Fixes 13e2e9c6b348 ("wifi: mt76: mt7996: use mac80211 .sta_state op")
Fixes 28d519d0d493 ("wifi: mt76: Move RCU section in mt7996_mcu_add_rate_ctrl_fixed()")

---
Found by code review. Tested in a QEMU guest with KASAN and a test hook that reassociates a station through mt7996_sta_state() on a synthetic device whose firmware commands are captured: without this change the second association hit a NULL pointer dereference in mt7996_mcu_add_rate_ctrl(), with it the association completed.

No new W=1, sparse or smatch warnings.

AI assistance was used.

 drivers/net/wireless/mediatek/mt76/mt7996/main.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7996/main.c +4 -0
index 9321c8146e2a..77f0664fe57c 100644
@@ -1491,6 +1491,10 @@ mt7996_mac_sta_links_event(struct mt7996_dev *dev, struct ieee80211_vif *vif,
 
 		switch (ev) {
 		case MT76_STA_EVENT_ASSOC:
+			/* Restore the station state that DISASSOC cleared */
+			msta_link->wcid.sta = 1;
+			msta_link->wcid.sta_disabled = 0;
+
 			err = mt7996_mcu_add_sta(dev, link_conf, link_sta,
 						 link, msta_link,
 						 CONN_STATE_CONNECT, true);

base-commit: 763b13f622e2758726e8e3ecaef819db8fa0430a

Signature · 1 line
2.56.1