From owner-svn-src-stable@freebsd.org Fri Aug 17 03:03:28 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7F9B1107FACA; Fri, 17 Aug 2018 03:03:28 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1F85E88E1C; Fri, 17 Aug 2018 03:03:28 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D5C1022984; Fri, 17 Aug 2018 03:03:27 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w7H33Rot010699; Fri, 17 Aug 2018 03:03:27 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7H33RPc010698; Fri, 17 Aug 2018 03:03:27 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201808170303.w7H33RPc010698@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Fri, 17 Aug 2018 03:03:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r337950 - stable/11/sys/net80211 X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/sys/net80211 X-SVN-Commit-Revision: 337950 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Aug 2018 03:03:28 -0000 Author: kevans Date: Fri Aug 17 03:03:27 2018 New Revision: 337950 URL: https://svnweb.freebsd.org/changeset/base/337950 Log: MFC r336184: 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. Modified: stable/11/sys/net80211/ieee80211.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/net80211/ieee80211.c ============================================================================== --- stable/11/sys/net80211/ieee80211.c Fri Aug 17 03:01:01 2018 (r337949) +++ stable/11/sys/net80211/ieee80211.c Fri Aug 17 03:03:27 2018 (r337950) @@ -247,14 +247,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); } @@ -356,6 +356,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); @@ -635,7 +644,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 @@ -1356,7 +1365,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, @@ -1954,13 +1963,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 */