public inbox for linux-mediatek@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] wifi: mt76: mt7996: avoid potential null deref in mt7996_get_et_stats()
@ 2025-03-22 14:19 Qasim Ijaz
  2025-03-22 14:55 ` Markus Elfring
  0 siblings, 1 reply; 7+ messages in thread
From: Qasim Ijaz @ 2025-03-22 14:19 UTC (permalink / raw)
  To: nbd, lorenzo, ryder.lee, shayne.chen, sean.wang, matthias.bgg,
	angelogioacchino.delregno, chui-hao.chiu, Bo.Jiao
  Cc: linux-wireless, linux-kernel, linux-arm-kernel, linux-mediatek

Ensure phy->mib is only accessed after the null sanity check for phy
otherwise the code may trigger a potential null deref.

Signed-off-by: Qasim Ijaz <qasdev00@gmail.com>
---
 drivers/net/wireless/mediatek/mt76/mt7996/main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
index 88e013577c0d..19391966ee3e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
@@ -1875,7 +1875,7 @@ void mt7996_get_et_stats(struct ieee80211_hw *hw,
 	struct mt7996_dev *dev = mt7996_hw_dev(hw);
 	struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
 	struct mt7996_phy *phy = mt7996_vif_link_phy(&mvif->deflink);
-	struct mt76_mib_stats *mib = &phy->mib;
+	struct mt76_mib_stats *mib;
 	struct mt76_ethtool_worker_info wi = {
 		.data = data,
 		.idx = mvif->deflink.mt76.idx,
@@ -1886,6 +1886,8 @@ void mt7996_get_et_stats(struct ieee80211_hw *hw,
 	if (!phy)
 		return;
 
+	mib = &phy->mib;
+	
 	mutex_lock(&dev->mt76.mutex);
 
 	mt7996_mac_update_stats(phy);
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-03-24  7:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-22 14:19 [PATCH] wifi: mt76: mt7996: avoid potential null deref in mt7996_get_et_stats() Qasim Ijaz
2025-03-22 14:55 ` Markus Elfring
2025-03-22 15:54   ` Johannes Berg
2025-03-23 11:59     ` James Dutton
2025-03-24  5:50       ` Dan Carpenter
2025-03-24  7:33         ` Markus Elfring
2025-03-24  7:43           ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox