Avoid kernel panic and returns 802.11b.
authorbenoit <benoit@0192ed92-7a03-0410-a25b-9323aeb14dbd>
Sat, 11 Jul 2009 17:33:54 +0000 (17:33 +0000)
committerbenoit <benoit@0192ed92-7a03-0410-a25b-9323aeb14dbd>
Sat, 11 Jul 2009 17:33:54 +0000 (17:33 +0000)
Merge from branches/madwifi-dfs@3649

git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@4078 0192ed92-7a03-0410-a25b-9323aeb14dbd

net80211/ieee80211.c

index 9a978c58962ab16738f6e7e9daf14a319128e1a0..fd39f6f8584460b50fd0c2f61f407eda5c243d39 100644 (file)
@@ -1578,11 +1578,19 @@ enum ieee80211_phymode
 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;