Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wifi: mt76: scan: Fix 'mlink' dereferenced before IS_ERR_OR_NULL check

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202504011739.HvUKtUUe-lkp@intel.com/
Fixes: 3ba20af886d1 ("wifi: mt76: scan: set vif offchannel link for scanning/roc")
Signed-off-by: Feng Jiang <jiangfeng@kylinos.cn>
Link: https://patch.msgid.link/20250402062415.25434-1-jiangfeng@kylinos.cn
Signed-off-by: Felix Fietkau <nbd@nbd.name>

authored by

Feng Jiang and committed by
Felix Fietkau
7e1fcf68 c29f2c77

+3 -1
+3 -1
drivers/net/wireless/mediatek/mt76/channel.c
··· 302 302 struct mt76_vif_link *mlink) 303 303 { 304 304 struct mt76_dev *dev = phy->dev; 305 - struct mt76_vif_data *mvif = mlink->mvif; 305 + struct mt76_vif_data *mvif; 306 306 307 307 if (IS_ERR_OR_NULL(mlink) || !mlink->offchannel) 308 308 return; 309 + 310 + mvif = mlink->mvif; 309 311 310 312 rcu_assign_pointer(mvif->offchannel_link, NULL); 311 313 dev->drv->vif_link_remove(phy, vif, &vif->bss_conf, mlink);