ieee80211_chan2mode(const struct ieee80211_channel *chan)
{
/*
- * Callers should handle this case properly, rather than
- * just relying that this function returns a sane value.
- * XXX: Probably needs to be revised.
+ * Callers should handle this case properly, rather than just relying
+ * that this function returns a sane value. XXX: Probably needs to be
+ * revised. chan is undefined if channel is 0 for instance and kernel
+ * panic would happen when called by ieee80211_sta_join1() in IBSS
+ * mode.
*/
- KASSERT(chan != IEEE80211_CHAN_ANYC, ("channel not setup"));
+
+ if (chan == NULL ||
+ chan == IEEE80211_CHAN_ANYC) {
+ printk(KERN_ERR "%s: BUG channel not setup: %p\n",
+ __func__, chan);
+ return IEEE80211_MODE_11B;
+ }
if (IEEE80211_IS_CHAN_108G(chan))
return IEEE80211_MODE_TURBO_G;