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