wifi: mt76: fix possible NULL access in mt76_tx
Subsystems (2)
PATCH 1/1 wifi: mt76: fix possible NULL access in mt76_tx
Add WARN_ON(!wcid) early return and drop redundant wcid NULL check
Co-developed-by Anthony Liu <[email protected]>
Signed-off-by Anthony Liu <[email protected]>
Signed-off-by Eason Lai <[email protected]>
--- drivers/net/wireless/mediatek/mt76/tx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/tx.c +2 -2
@@ -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
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
Co-developed-by Anthony Liu <[email protected]>Signed-off-by Anthony Liu <[email protected]>Signed-off-by Eason Lai <[email protected]>--- drivers/net/wireless/mediatek/mt76/tx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/wireless/mediatek/mt76/tx.c +2
-2@@ -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
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 checkMaybe
WARN_ON_ONCEis 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