Author: avos
Date: Sun Jul 30 18:38:05 2017
New Revision: 321725
URL: https://svnweb.freebsd.org/changeset/base/321725

Log:
  MFC r321401:
  net80211: do not allow to unload rate control module if it is still in use.
  
  Keep 'nrefs' counter up-to-date, so 'kldunload wlan_amrr' with 1+ active
  wlan(4) interface will not lead to kernel panic.

Modified:
  stable/10/sys/net80211/ieee80211_amrr.c
  stable/10/sys/net80211/ieee80211_rssadapt.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/net80211/ieee80211_amrr.c
==============================================================================
--- stable/10/sys/net80211/ieee80211_amrr.c     Sun Jul 30 18:29:28 2017        
(r321724)
+++ stable/10/sys/net80211/ieee80211_amrr.c     Sun Jul 30 18:38:05 2017        
(r321725)
@@ -111,6 +111,7 @@ amrr_init(struct ieee80211vap *vap)
 
        KASSERT(vap->iv_rs == NULL, ("%s called multiple times", __func__));
 
+       nrefs++;                /* XXX locking */
        amrr = vap->iv_rs = malloc(sizeof(struct ieee80211_amrr),
            M_80211_RATECTL, M_NOWAIT|M_ZERO);
        if (amrr == NULL) {
@@ -127,6 +128,8 @@ static void
 amrr_deinit(struct ieee80211vap *vap)
 {
        free(vap->iv_rs, M_80211_RATECTL);
+       KASSERT(nrefs > 0, ("imbalanced attach/detach"));
+       nrefs--;                /* XXX locking */
 }
 
 static int

Modified: stable/10/sys/net80211/ieee80211_rssadapt.c
==============================================================================
--- stable/10/sys/net80211/ieee80211_rssadapt.c Sun Jul 30 18:29:28 2017        
(r321724)
+++ stable/10/sys/net80211/ieee80211_rssadapt.c Sun Jul 30 18:38:05 2017        
(r321725)
@@ -127,7 +127,8 @@ rssadapt_init(struct ieee80211vap *vap)
 
        KASSERT(vap->iv_rs == NULL, ("%s: iv_rs already initialized",
            __func__));
-       
+
+       nrefs++;                /* XXX locking */
        vap->iv_rs = rs = malloc(sizeof(struct ieee80211_rssadapt),
            M_80211_RATECTL, M_NOWAIT|M_ZERO);
        if (rs == NULL) {
@@ -143,6 +144,8 @@ static void
 rssadapt_deinit(struct ieee80211vap *vap)
 {
        free(vap->iv_rs, M_80211_RATECTL);
+       KASSERT(nrefs > 0, ("imbalanced attach/detach"));
+       nrefs--;                /* XXX locking */
 }
 
 static void
_______________________________________________
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"

Reply via email to