From: Alexander Sverdlin Since commit 0d9c2beed116 ("wifi: mac80211: fix monitor channel with chanctx emulation"), the virtual monitor is always allocated, but the driver is only told about it with WANT_MONITOR_VIF. That works for drivers using chanctx emulation, as drv_assign_vif_chanctx() skips such a monitor for them. A driver with real chanctx ops but without WANT_MONITOR_VIF however gets asked to bind a chanctx to a vif it has never seen. check_sdata_in_driver() fails with -EIO, and the error path then removes the never-added interface from the driver: phy0-monitor: Failed check-sdata-in-driver check, flags: 0x0 WARNING: ... at net/mac80211/driver-ops.c:334 drv_assign_vif_chanctx+0x314/0x340 drv_assign_vif_chanctx+0x314/0x340 ieee80211_assign_link_chanctx+0x90/0x480 _ieee80211_link_use_channel+0x310/0x3d0 ieee80211_add_virtual_monitor+0x154/0x2c8 ieee80211_do_stop+0x864/0x898 ieee80211_stop+0x6c/0x100 WARNING: ... at net/mac80211/driver-ops.c:114 drv_remove_interface+0x10c/0x290 The first comes from stopping the last non-monitor interface while a monitor interface is up. A monitor interface also can no longer be brought up on its own, as ieee80211_do_open() fails with -EIO. Such a monitor has nothing to offer these drivers anyway, so don't create it, as was the case before that commit. Also only remove it from the driver on the error path if it was added there. Affected are wfx and wlcore. Fixes: 0d9c2beed116 ("wifi: mac80211: fix monitor channel with chanctx emulation") Cc: stable@vger.kernel.org Signed-off-by: Alexander Sverdlin --- net/mac80211/iface.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 588f26611a101..971e7cee4939b 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -1306,6 +1306,11 @@ int ieee80211_add_virtual_monitor(struct ieee80211_local *local, if (ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR)) return 0; + /* a real chanctx can only be bound to a vif the driver knows */ + if (!local->emulate_chanctx && + !ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) + return 0; + /* Already have a monitor set up, configure it */ sdata = wiphy_dereference(local->hw.wiphy, local->monitor_sdata); if (sdata) @@ -1354,7 +1359,8 @@ int ieee80211_add_virtual_monitor(struct ieee80211_local *local, RCU_INIT_POINTER(local->monitor_sdata, NULL); mutex_unlock(&local->iflist_mtx); synchronize_net(); - drv_remove_interface(local, sdata); + if (ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) + drv_remove_interface(local, sdata); clear_bit(SDATA_STATE_RUNNING, &sdata->state); kfree(sdata); return ret; -- 2.56.1