blob: 8839a7151bb9421df186626003d4d3475b1a2596 [file] [log] [blame]
developera46f6132024-03-26 14:09:54 +08001From 5cb8c91ff8f579d192f93e258314199fc33355c8 Mon Sep 17 00:00:00 2001
developer1a173672023-12-21 14:49:33 +08002From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Mon, 30 Oct 2023 11:06:19 +0800
developera46f6132024-03-26 14:09:54 +08004Subject: [PATCH 14/17] mtk: wifi: mt76: add sanity check to prevent kernel
developer1a173672023-12-21 14:49:33 +08005 crash
6
7wcid may not be initialized when mac80211 calls mt76.tx and it would lead to
8kernel crash.
9
10Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
11---
12 tx.c | 8 ++++++++
13 1 file changed, 8 insertions(+)
14
15diff --git a/tx.c b/tx.c
developera46f6132024-03-26 14:09:54 +080016index 5cf6edee..ab42f69b 100644
developer1a173672023-12-21 14:49:33 +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--
352.18.0
36