Skip to contentSkip to conversation

wifi: mt76: fix possible NULL access in mt76_tx

PATCH In review Eason Lai 2 participants 3 messages Nov 26 – Nov 27

Subsystems (2)
lore
Share & tools
lore

Eason Lai

author
#0 lore raw

PATCH 1/1 wifi: mt76: fix possible NULL access in mt76_tx

Add WARN_ON(!wcid) early return and drop redundant wcid NULL check

---
 drivers/net/wireless/mediatek/mt76/tx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/tx.c +2 -2
index d8036466f495..2be43d05c9af 100644
@@ -377,7 +377,7 @@ mt76_tx(struct mt76_phy *phy, struct ieee80211_sta *sta,
 	struct mt76_dev *dev = phy->dev;
 	struct sk_buff_head *head;
 
-	if (mt76_testmode_enabled(phy)) {
+	if (WARN_ON(!wcid) || mt76_testmode_enabled(phy)) {
 		ieee80211_free_txskb(phy->hw, skb);
 		return;
 	}
@@ -385,7 +385,7 @@ mt76_tx(struct mt76_phy *phy, struct ieee80211_sta *sta,
 	if (WARN_ON(skb_get_queue_mapping(skb) >= MT_TXQ_PSD))
 		skb_set_queue_mapping(skb, MT_TXQ_BE);
 
-	if (wcid && !(wcid->tx_info & MT_WCID_TX_INFO_SET))
+	if (!(wcid->tx_info & MT_WCID_TX_INFO_SET))
 		ieee80211_get_tx_rates(info->control.vif, sta, skb,
 				       info->control.rates, 1);
 
Signature · 1 line
2.45.2
#1 lore raw
Quoted 1 line · Eason Lai

Add WARN_ON(!wcid) early return and drop redundant wcid NULL check

Maybe WARN_ON_ONCE is better, to decrease potential log spam in case this problem can happen often in some cases?

Thanks,
Ben

Quoted 30 lines
---
  drivers/net/wireless/mediatek/mt76/tx.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/tx.c +2 -2
index d8036466f495..2be43d05c9af 100644
@@ -377,7 +377,7 @@ mt76_tx(struct mt76_phy *phy, struct ieee80211_sta *sta,
  	struct mt76_dev *dev = phy->dev;
  	struct sk_buff_head *head;
 
-	if (mt76_testmode_enabled(phy)) {
+	if (WARN_ON(!wcid) || mt76_testmode_enabled(phy)) {
  		ieee80211_free_txskb(phy->hw, skb);
  		return;
  	}
@@ -385,7 +385,7 @@ mt76_tx(struct mt76_phy *phy, struct ieee80211_sta *sta,
  	if (WARN_ON(skb_get_queue_mapping(skb) >= MT_TXQ_PSD))
  		skb_set_queue_mapping(skb, MT_TXQ_BE);
 
-	if (wcid && !(wcid->tx_info & MT_WCID_TX_INFO_SET))
+	if (!(wcid->tx_info & MT_WCID_TX_INFO_SET))
  		ieee80211_get_tx_rates(info->control.vif, sta, skb,
  				       info->control.rates, 1);
 
Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
#2 lore raw
Quoted 11 lines · Ben Greear

External email : Please do not click links or open attachments until you have verified the sender or the content.

Quoted 1 line · Eason Lai

Add WARN_ON(!wcid) early return and drop redundant wcid NULL check

Maybe WARN_ON_ONCE is better, to decrease potential log spam in case this problem can happen often in some cases?

Make sense. I will update it to WARN_ON_ONCE() in v2.

Thanks,
Eason

Quoted 4 lines

Thanks,
Ben