developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame^] | 1 | From 49a1a916113cf23ad38ef6e3f3cfd0279f7abea4 Mon Sep 17 00:00:00 2001 |
| 2 | From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 3 | Date: Mon, 30 Oct 2023 11:06:19 +0800 |
| 4 | Subject: [PATCH 017/116] mtk: wifi: mt76: add sanity check to prevent kernel |
| 5 | crash |
| 6 | |
| 7 | wcid may not be initialized when mac80211 calls mt76.tx and it would lead to |
| 8 | kernel crash. |
| 9 | |
| 10 | CR-Id: WCNCR00240772 |
| 11 | Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 12 | Change-Id: I90004271c6e91620c6991195dd332780ce28380e |
| 13 | --- |
| 14 | tx.c | 8 ++++++++ |
| 15 | 1 file changed, 8 insertions(+) |
| 16 | |
| 17 | diff --git a/tx.c b/tx.c |
| 18 | index 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 | -- |
| 37 | 2.39.2 |
| 38 | |