blob: 7030800805cfc0106025ef0aa2ad2403c96ffcc4 [file] [log] [blame]
From a51ea8a1b4d04afbd26882f35e04c60d7fee5fbd Mon Sep 17 00:00:00 2001
From: Peter Chiu <chui-hao.chiu@mediatek.com>
Date: Mon, 30 Oct 2023 11:06:19 +0800
Subject: [PATCH 020/120] mtk: wifi: mt76: add sanity check to prevent kernel
crash
wcid may not be initialized when mac80211 calls mt76.tx and it would lead to
kernel crash.
CR-Id: WCNCR00240772
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Change-Id: I90004271c6e91620c6991195dd332780ce28380e
---
tx.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tx.c b/tx.c
index 5cf6edee4..ab42f69b8 100644
--- a/tx.c
+++ b/tx.c
@@ -345,6 +345,14 @@ mt76_tx(struct mt76_phy *phy, struct ieee80211_sta *sta,
info->hw_queue |= FIELD_PREP(MT_TX_HW_QUEUE_PHY, phy->band_idx);
+ if (!wcid->tx_pending.prev || !wcid->tx_pending.next) {
+ dev_warn(phy->dev->dev, "Un-initialized STA %pM wcid %d in mt76_tx\n",
+ sta->addr, wcid->idx);
+
+ ieee80211_free_txskb(phy->hw, skb);
+ return;
+ }
+
spin_lock_bh(&wcid->tx_pending.lock);
__skb_queue_tail(&wcid->tx_pending, skb);
spin_unlock_bh(&wcid->tx_pending.lock);
--
2.39.2