From owner-svn-src-head@freebsd.org Wed Jul 26 05:29:09 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4F18FDB1CBC; Wed, 26 Jul 2017 05:29:09 +0000 (UTC) (envelope-from adrian@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 mx1.freebsd.org (Postfix) with ESMTPS id 2B2EE75B59; Wed, 26 Jul 2017 05:29:09 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v6Q5T8mk094496; Wed, 26 Jul 2017 05:29:08 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v6Q5T8q6094494; Wed, 26 Jul 2017 05:29:08 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201707260529.v6Q5T8q6094494@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Wed, 26 Jul 2017 05:29:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r321508 - head/sys/dev/iwm X-SVN-Group: head X-SVN-Commit-Author: adrian X-SVN-Commit-Paths: head/sys/dev/iwm X-SVN-Commit-Revision: 321508 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Jul 2017 05:29:09 -0000 Author: adrian Date: Wed Jul 26 05:29:08 2017 New Revision: 321508 URL: https://svnweb.freebsd.org/changeset/base/321508 Log: [iwm] Cleanup mbufq draining. Add iwm_xmit_queue_drain() like in iwn(4). * iwm_xmit_queue_drain() calls ieee80211_free_node(), removing a possible memory leak, compared to using just mbufq_drain(). * Remove duplicate mbufq_drain() from iwm_mvm_rm_sta(), this should be handled in the caller. Obtained from: dragonflybsd.git 339d45fda40072e0aca5ece639173204716f11fe Modified: head/sys/dev/iwm/if_iwm.c head/sys/dev/iwm/if_iwm_sta.c Modified: head/sys/dev/iwm/if_iwm.c ============================================================================== --- head/sys/dev/iwm/if_iwm.c Wed Jul 26 05:26:01 2017 (r321507) +++ head/sys/dev/iwm/if_iwm.c Wed Jul 26 05:29:08 2017 (r321508) @@ -388,6 +388,7 @@ static struct ieee80211vap * const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN]); static void iwm_vap_delete(struct ieee80211vap *); +static void iwm_xmit_queue_drain(struct iwm_softc *); static void iwm_scan_start(struct ieee80211com *); static void iwm_scan_end(struct ieee80211com *); static void iwm_update_mcast(struct ieee80211com *); @@ -4103,7 +4104,7 @@ iwm_release(struct iwm_softc *sc, struct iwm_node *in) * get here from RUN state. */ tfd_msk = 0xf; - mbufq_drain(&sc->sc_snd); + iwm_xmit_queue_drain(sc); iwm_mvm_flush_tx_path(sc, tfd_msk, IWM_CMD_SYNC); /* * We seem to get away with just synchronously sending the @@ -6214,6 +6215,19 @@ iwm_vap_delete(struct ieee80211vap *vap) } static void +iwm_xmit_queue_drain(struct iwm_softc *sc) +{ + struct mbuf *m; + struct ieee80211_node *ni; + + while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { + ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; + ieee80211_free_node(ni); + m_freem(m); + } +} + +static void iwm_scan_start(struct ieee80211com *ic) { struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); @@ -6372,6 +6386,9 @@ iwm_detach_local(struct iwm_softc *sc, int do_net80211 callout_drain(&sc->sc_watchdog_to); iwm_stop_device(sc); if (do_net80211) { + IWM_LOCK(sc); + iwm_xmit_queue_drain(sc); + IWM_UNLOCK(sc); ieee80211_ifdetach(&sc->sc_ic); } @@ -6405,7 +6422,6 @@ iwm_detach_local(struct iwm_softc *sc, int do_net80211 sc->sc_notif_wait = NULL; } - mbufq_drain(&sc->sc_snd); IWM_LOCK_DESTROY(sc); return (0); Modified: head/sys/dev/iwm/if_iwm_sta.c ============================================================================== --- head/sys/dev/iwm/if_iwm_sta.c Wed Jul 26 05:26:01 2017 (r321507) +++ head/sys/dev/iwm/if_iwm_sta.c Wed Jul 26 05:29:08 2017 (r321508) @@ -283,7 +283,6 @@ iwm_mvm_rm_sta(struct iwm_softc *sc, struct ieee80211v ret = iwm_mvm_drain_sta(sc, IWM_VAP(vap), TRUE); if (ret) return ret; - mbufq_drain(&sc->sc_snd); /* XXX needed ? */ for (ac = 0; ac < WME_NUM_AC; ac++) { tfd_queue_msk |= htole32(1 << iwm_mvm_ac_to_tx_fifo[ac]); }