[PATCH] wifi: mt76: mt7996: avoid potential null deref in mt7996_get_et_stats()

Markus Elfring Markus.Elfring at web.de
Sat Mar 22 07:55:49 PDT 2025


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

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

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


…
> +++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
…
> @@ -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);

I suggest to move such an assignment statement directly before the place
where this variable is used finally.

Regards,
Markus



More information about the linux-arm-kernel mailing list