diff options
author | rpaulo <rpaulo@FreeBSD.org> | 2010-04-09 12:06:19 +0000 |
---|---|---|
committer | rpaulo <rpaulo@FreeBSD.org> | 2010-04-09 12:06:19 +0000 |
commit | 6e781e21dbc7cd56e89be117eca5be95fa79b65b (patch) | |
tree | 4b433dd899472acc3a80500bf822820189e50cc1 | |
parent | a5b2b30f957074bb4016f69e20d7b2520e658b46 (diff) | |
download | FreeBSD-src-6e781e21dbc7cd56e89be117eca5be95fa79b65b.zip FreeBSD-src-6e781e21dbc7cd56e89be117eca5be95fa79b65b.tar.gz |
Use M_NOWAIT instead of M_WAITOK to avoid race conditions.
MFC after: 1 month
-rw-r--r-- | sys/net80211/ieee80211_amrr.c | 19 | ||||
-rw-r--r-- | sys/net80211/ieee80211_rssadapt.c | 22 |
2 files changed, 28 insertions, 13 deletions
diff --git a/sys/net80211/ieee80211_amrr.c b/sys/net80211/ieee80211_amrr.c index e8eed09..6111058 100644 --- a/sys/net80211/ieee80211_amrr.c +++ b/sys/net80211/ieee80211_amrr.c @@ -110,9 +110,12 @@ amrr_init(struct ieee80211vap *vap) KASSERT(vap->iv_rs == NULL, ("%s called multiple times", __func__)); - vap->iv_rs = malloc(sizeof(struct ieee80211_amrr), M_80211_RATECTL, - M_WAITOK|M_ZERO); - amrr = vap->iv_rs; + amrr = vap->iv_rs = malloc(sizeof(struct ieee80211_amrr), + M_80211_RATECTL, M_NOWAIT|M_ZERO); + if (amrr == NULL) { + if_printf(vap->iv_ifp, "couldn't alloc ratectl structure\n"); + return; + } amrr->amrr_min_success_threshold = IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD; amrr->amrr_max_success_threshold = IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD; amrr_setinterval(vap, 500 /* ms */); @@ -136,9 +139,13 @@ amrr_node_init(struct ieee80211_node *ni) KASSERT(ni->ni_rctls == NULL, ("%s: ni_rctls already initialized", __func__)); - ni->ni_rctls = malloc(sizeof(struct ieee80211_amrr_node), - M_80211_RATECTL, M_WAITOK|M_ZERO); - amn = ni->ni_rctls; + ni->ni_rctls = amn = malloc(sizeof(struct ieee80211_amrr_node), + M_80211_RATECTL, M_NOWAIT|M_ZERO); + if (amn == NULL) { + if_printf(vap->iv_ifp, "couldn't alloc per-node ratectl " + "structure\n"); + return; + } amn->amn_amrr = amrr; amn->amn_success = 0; amn->amn_recovery = 0; diff --git a/sys/net80211/ieee80211_rssadapt.c b/sys/net80211/ieee80211_rssadapt.c index e90ad57..ad329e0 100644 --- a/sys/net80211/ieee80211_rssadapt.c +++ b/sys/net80211/ieee80211_rssadapt.c @@ -128,9 +128,12 @@ rssadapt_init(struct ieee80211vap *vap) KASSERT(vap->iv_rs == NULL, ("%s: iv_rs already initialized", __func__)); - rs = malloc(sizeof(struct ieee80211_rssadapt), M_80211_RATECTL, - M_WAITOK|M_ZERO); - vap->iv_rs = rs; + vap->iv_rs = rs = malloc(sizeof(struct ieee80211_rssadapt), + M_80211_RATECTL, M_NOWAIT|M_ZERO); + if (rs == NULL) { + if_printf(vap->iv_ifp, "couldn't alloc ratectl structure\n"); + return; + } rs->vap = vap; rssadapt_setinterval(vap, 500 /* msecs */); rssadapt_sysctlattach(vap, vap->iv_sysctl, vap->iv_oid); @@ -162,12 +165,17 @@ static void rssadapt_node_init(struct ieee80211_node *ni) { struct ieee80211_rssadapt_node *ra; - struct ieee80211_rssadapt *rsa = ni->ni_vap->iv_rs; + struct ieee80211vap *vap = ni->ni_vap; + struct ieee80211_rssadapt *rsa = vap->iv_rs; const struct ieee80211_rateset *rs = &ni->ni_rates; - ra = malloc(sizeof(struct ieee80211_rssadapt_node), M_80211_RATECTL, - M_WAITOK|M_ZERO); - ni->ni_rctls = ra; + ni->ni_rctls = ra = malloc(sizeof(struct ieee80211_rssadapt_node), + M_80211_RATECTL, M_NOWAIT|M_ZERO); + if (ra == NULL) { + if_printf(vap->iv_ifp, "couldn't alloc per-node ratectl " + "structure\n"); + return; + } ra->ra_rs = rsa; ra->ra_rates = *rs; rssadapt_updatestats(ra); |