Created attachment 160122 [details] Fix the issue and remove workaround from the wpi driver In case, when interface is recreated (create -> destroy -> create), some values (like ic->ic_curchan) are left unchanged and may be incompatible with new mode. As an example: 1) ifconfig wlan0 create wlandev <dev> wlanmode ahdemo channel <some NOADHOC channel> 2) ifconfig wlan0 destroy 3) ifconfig wlan0 create wlandev <dev> wlanmode ibss ssid ssid 4) ifconfig wlan0 up may result in incorrect ic->ic_curchan value passed into driver and may lead to crash (for example, wpi firmware throws an error here). This patch adds a check into ieee80211_start_locked() and resets ic->ic_curchan to &ic->ic_channels[0] when the channel is incompatible with current mode.
A commit references this bug: Author: adrian Date: Sun Aug 23 01:17:53 UTC 2015 New revision: 287029 URL: https://svnweb.freebsd.org/changeset/base/287029 Log: Reset the channel to the first available channel if the interface is configured on a channel that isn't valid in the new operating mode. This isn't strictly true - it should find the first channel that is available for the given operating mode. However, I think defaulting to the first channel is fine - it's typically available for all modes. If someone would like to correctly implement this feature - try to find a channel that is valid for the given operating mode and error out if we can't find one. This prevents various NICs (eg wpi(4)) from throwing a firmware error. Tested: * ath(4), STA/AP mode * iwn(4), STA/adhoc mode PR: kern/202502 Submitted by: Andriy Voskoboinyk <s3erios@gmail.com> Changes: head/sys/net80211/ieee80211_proto.c