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