Author: kevans
Date: Tue Jul 10 23:30:19 2018
New Revision: 336184
URL: https://svnweb.freebsd.org/changeset/base/336184

Log:
  net80211: Fix ifdetach w/o ifattach, small whitespace cleanup
  
  As the comment says, ifdetach might be called during the course of driver
  detach if initialization failed. This shouldn't be a total failure, though,
  we just have nothing to do there.
  
  This has been modified slightly from Augustin's original commit to move the
  bail-out slightly earlier since the ic wouldn't have been added to the
  ic list in the first place, and a comment has been added describing when
  this might be an issue.
  
  Submitted by: Augustin Cavalier <waddlespl...@gmail.com>
  Obtained from:        Haiku (e6f6c1b4633532a8ad37c803dc7c65601e5b24ba)

Modified:
  head/sys/net80211/ieee80211.c

Modified: head/sys/net80211/ieee80211.c
==============================================================================
--- head/sys/net80211/ieee80211.c       Tue Jul 10 22:53:07 2018        
(r336183)
+++ head/sys/net80211/ieee80211.c       Tue Jul 10 23:30:19 2018        
(r336184)
@@ -276,14 +276,14 @@ null_update_chw(struct ieee80211com *ic)
 
 int
 ic_printf(struct ieee80211com *ic, const char * fmt, ...)
-{ 
+{
        va_list ap;
        int retval;
 
        retval = printf("%s: ", ic->ic_name);
        va_start(ap, fmt);
        retval += vprintf(fmt, ap);
-       va_end(ap);  
+       va_end(ap);
        return (retval);
 }
 
@@ -386,6 +386,15 @@ ieee80211_ifdetach(struct ieee80211com *ic)
 {
        struct ieee80211vap *vap;
 
+       /*
+        * We use this as an indicator that ifattach never had a chance to be
+        * called, e.g. early driver attach failed and ifdetach was called
+        * during subsequent detach.  Never fear, for we have nothing to do
+        * here.
+        */
+       if (ic->ic_tq == NULL)
+               return;
+
        mtx_lock(&ic_list_mtx);
        LIST_REMOVE(ic, ic_next);
        mtx_unlock(&ic_list_mtx);
@@ -702,7 +711,7 @@ ieee80211_vap_attach(struct ieee80211vap *vap, ifm_cha
        return 1;
 }
 
-/* 
+/*
  * Tear down vap state and reclaim the ifnet.
  * The driver is assumed to have prepared for
  * this; e.g. by turning off interrupts for the
@@ -1760,7 +1769,7 @@ addmedia(struct ifmedia *media, int caps, int addsta, 
 #define        ADD(_ic, _s, _o) \
        ifmedia_add(media, \
                IFM_MAKEWORD(IFM_IEEE80211, (_s), (_o), 0), 0, NULL)
-       static const u_int mopts[IEEE80211_MODE_MAX] = { 
+       static const u_int mopts[IEEE80211_MODE_MAX] = {
            [IEEE80211_MODE_AUTO]       = IFM_AUTO,
            [IEEE80211_MODE_11A]        = IFM_IEEE80211_11A,
            [IEEE80211_MODE_11B]        = IFM_IEEE80211_11B,
@@ -2386,13 +2395,13 @@ ieee80211_rate2media(struct ieee80211com *ic, int rate
        case IEEE80211_MODE_11NA:
        case IEEE80211_MODE_TURBO_A:
        case IEEE80211_MODE_STURBO_A:
-               return findmedia(rates, nitems(rates), 
+               return findmedia(rates, nitems(rates),
                    rate | IFM_IEEE80211_11A);
        case IEEE80211_MODE_11B:
-               return findmedia(rates, nitems(rates), 
+               return findmedia(rates, nitems(rates),
                    rate | IFM_IEEE80211_11B);
        case IEEE80211_MODE_FH:
-               return findmedia(rates, nitems(rates), 
+               return findmedia(rates, nitems(rates),
                    rate | IFM_IEEE80211_FH);
        case IEEE80211_MODE_AUTO:
                /* NB: ic may be NULL for some drivers */
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to