Skip to contentSkip to conversation

wifi: mt76: mt7996: avoid null deref in mt7996_stop_phy()

PATCH In review Qasim Ijaz 2 participants 2 messages Mar 22, 2025

Subsystems (2)
lore
Share & tools
lore

Qasim Ijaz

author
#0 lore raw

PATCH 1/1 wifi: mt76: mt7996: avoid null deref in mt7996_stop_phy()

In mt7996_stop_phy() the mt7996_phy structure is dereferenced before the null sanity check which could lead to a null deref.

Fix by moving the dereference operation after the
sanity check.

Fixes 69d54ce7491d ("wifi: mt76: mt7996: switch to single multi-radio wiphy")
---
 drivers/net/wireless/mediatek/mt76/mt7996/main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7996/main.c +3 -1
index 66575698aef1..88e013577c0d 100644
@@ -68,11 +68,13 @@ static int mt7996_start(struct ieee80211_hw *hw)
 
 static void mt7996_stop_phy(struct mt7996_phy *phy)
 {
-	struct mt7996_dev *dev = phy->dev;
+	struct mt7996_dev *dev;
 
 	if (!phy || !test_bit(MT76_STATE_RUNNING, &phy->mt76->state))
 		return;
 
+	dev = phy->dev;
+
 	cancel_delayed_work_sync(&phy->mt76->mac_work);
 
 	mutex_lock(&dev->mt76.mutex);
Signature · 1 line
2.39.5
#1 lore raw
Quoted 6 lines

In mt7996_stop_phy() the mt7996_phy structure is dereferenced before the null sanity check which could lead to a null deref.

Fix by moving the dereference operation after the
sanity check.

* You may occasionally put more than 53 characters into text lines of such a change description.

* Would you like to use the term “null pointer dereference” consistently?

* Were any known source code analysis tools involved also for this software improvement?

Regards,
Markus