[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
This commit is contained in:
Adrian Chadd 2017-07-26 05:29:08 +00:00
parent 2aa3dbb059
commit 7a3e63e7b3
2 changed files with 18 additions and 3 deletions

View File

@ -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
@ -6213,6 +6214,19 @@ iwm_vap_delete(struct ieee80211vap *vap)
free(ivp, M_80211_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)
{
@ -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);

View File

@ -283,7 +283,6 @@ iwm_mvm_rm_sta(struct iwm_softc *sc, struct ieee80211vap *vap,
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]);
}