blob: ebca1e837613cfddbf123ec2be341a271faf08a0 [file] [log] [blame]
developer9237f442024-06-14 17:13:04 +08001From cfac6751faf2d57e1d02c44984f220b770ac6cf3 Mon Sep 17 00:00:00 2001
developer66e89bc2024-04-23 14:50:01 +08002From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Mon, 30 Oct 2023 11:06:19 +0800
developer9237f442024-06-14 17:13:04 +08004Subject: [PATCH 016/116] mtk: wifi: mt76: add sanity check to prevent kernel
developer66e89bc2024-04-23 14:50:01 +08005 crash
6
7wcid may not be initialized when mac80211 calls mt76.tx and it would lead to
8kernel crash.
9
developer66e89bc2024-04-23 14:50:01 +080010Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
developer66e89bc2024-04-23 14:50:01 +080011---
12 tx.c | 8 ++++++++
13 1 file changed, 8 insertions(+)
14
15diff --git a/tx.c b/tx.c
developer9237f442024-06-14 17:13:04 +080016index 5cf6ede..ab42f69 100644
developer66e89bc2024-04-23 14:50:01 +080017--- a/tx.c
18+++ b/tx.c
19@@ -345,6 +345,14 @@ mt76_tx(struct mt76_phy *phy, struct ieee80211_sta *sta,
20
21 info->hw_queue |= FIELD_PREP(MT_TX_HW_QUEUE_PHY, phy->band_idx);
22
23+ if (!wcid->tx_pending.prev || !wcid->tx_pending.next) {
24+ dev_warn(phy->dev->dev, "Un-initialized STA %pM wcid %d in mt76_tx\n",
25+ sta->addr, wcid->idx);
26+
27+ ieee80211_free_txskb(phy->hw, skb);
28+ return;
29+ }
30+
31 spin_lock_bh(&wcid->tx_pending.lock);
32 __skb_queue_tail(&wcid->tx_pending, skb);
33 spin_unlock_bh(&wcid->tx_pending.lock);
34--
developer9237f442024-06-14 17:13:04 +0800352.18.0
developer66e89bc2024-04-23 14:50:01 +080036