blob: feb14a6dbffb5dce09a3a8c43e601bb22d8691b4 [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From 8c9cbc14f8956087c0262f0e9e943689a6b6b00a 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
developer05f3b2b2024-08-19 19:17:34 +08004Subject: [PATCH 022/199] mtk: mt76: add sanity check to prevent kernel crash
developer66e89bc2024-04-23 14:50:01 +08005
6wcid may not be initialized when mac80211 calls mt76.tx and it would lead to
7kernel crash.
8
developer66e89bc2024-04-23 14:50:01 +08009Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
developer66e89bc2024-04-23 14:50:01 +080010---
11 tx.c | 8 ++++++++
12 1 file changed, 8 insertions(+)
13
14diff --git a/tx.c b/tx.c
developer05f3b2b2024-08-19 19:17:34 +080015index 5cf6edee..ab42f69b 100644
developer66e89bc2024-04-23 14:50:01 +080016--- a/tx.c
17+++ b/tx.c
18@@ -345,6 +345,14 @@ mt76_tx(struct mt76_phy *phy, struct ieee80211_sta *sta,
19
20 info->hw_queue |= FIELD_PREP(MT_TX_HW_QUEUE_PHY, phy->band_idx);
21
22+ if (!wcid->tx_pending.prev || !wcid->tx_pending.next) {
23+ dev_warn(phy->dev->dev, "Un-initialized STA %pM wcid %d in mt76_tx\n",
24+ sta->addr, wcid->idx);
25+
26+ ieee80211_free_txskb(phy->hw, skb);
27+ return;
28+ }
29+
30 spin_lock_bh(&wcid->tx_pending.lock);
31 __skb_queue_tail(&wcid->tx_pending, skb);
32 spin_unlock_bh(&wcid->tx_pending.lock);
33--
developer9237f442024-06-14 17:13:04 +0800342.18.0
developer66e89bc2024-04-23 14:50:01 +080035