developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1 | From cfac6751faf2d57e1d02c44984f220b770ac6cf3 Mon Sep 17 00:00:00 2001 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2 | From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 3 | Date: Mon, 30 Oct 2023 11:06:19 +0800 |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 4 | Subject: [PATCH 016/116] mtk: wifi: mt76: add sanity check to prevent kernel |
developer | 66e89bc | 2024-04-23 14:50:01 +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 | |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 10 | Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 11 | --- |
| 12 | tx.c | 8 ++++++++ |
| 13 | 1 file changed, 8 insertions(+) |
| 14 | |
| 15 | diff --git a/tx.c b/tx.c |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 16 | index 5cf6ede..ab42f69 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +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 | -- |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 35 | 2.18.0 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 36 | |