[PATCH] wifi: mt76: connac: use wcid_to_sta() when dequeuing PM frames

From: Ziheng Wei

Date: Sun Nov 15 2026 - 03:03:36 EST


When the device is in runtime PM, mt792x_tx() cannot transmit right
away and queues the frame with mt76_connac_pm_queue_skb(), keeping only
the wcid. mt76_connac_pm_dequeue_skbs() later recovers the station
from that wcid with

sta = container_of((void *)wcid, struct ieee80211_sta, drv_priv);

This is only valid for the default link's wcid, which is embedded at
the start of struct mt792x_sta and therefore at drv_priv. Since MLO
support, mt792x_tx() queues the per-link wcid of the link the frame is
sent on. For any link other than the default one, that wcid lives in a
separately allocated struct mt792x_link_sta, so container_of() yields
a pointer 600 bytes (offsetof(struct ieee80211_sta, drv_priv) on
x86_64) before that allocation. mt76_tx() then passes it to mac80211,
which dereferences it as the station, e.g. in
rate_control_fill_sta_table() via ieee80211_get_tx_rates().

wcid_to_sta() in mt76.h follows wcid->def_wcid for link wcids and is
correct for both cases. Use it.

mt76_check_sta() in mac80211.c has the same pattern, but only uses the
result when MT_WCID_FLAG_CHECK_PS is set, which only mt76x02 and
mt7603 set; neither supports MLO, so it is left alone.

Found by LLM-assisted source review. Not tested on hardware. A test
module that queues a frame for a separately allocated link wcid and
calls mt76_connac_pm_dequeue_skbs() hits a KASAN slab-out-of-bounds
read in rate_control_fill_sta_table().

Fixes: ebb1406813c6 ("wifi: mt76: mt7925: add link handling to txwi")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Ziheng Wei <zihengw03@xxxxxxx>
---

Notes:
The changelog was drafted with an AI assistant from my analysis;
I have reviewed the code, the fix and the text.

drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
index 8481eac8d..6c2caade6 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
@@ -134,8 +134,7 @@ void mt76_connac_pm_dequeue_skbs(struct mt76_phy *phy,
continue;

if (wcid && wcid->sta)
- sta = container_of((void *)wcid, struct ieee80211_sta,
- drv_priv);
+ sta = wcid_to_sta(wcid);

mt76_tx(phy, sta, wcid, pm->tx_q[i].skb);
pm->tx_q[i].skb = NULL;

base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa
--
2.43.0