svn commit: r184210 - in head/sys: net80211 sys

Dag-Erling Smorgrav des at FreeBSD.org
Thu Oct 23 19:57:14 UTC 2008


Author: des
Date: Thu Oct 23 19:57:13 2008
New Revision: 184210
URL: http://svn.freebsd.org/changeset/base/184210

Log:
  Revert the removal of the MALLOC and FREE macros from the net80211 code.
  
  Requested by:	sam

Modified:
  head/sys/net80211/ieee80211_acl.c
  head/sys/net80211/ieee80211_crypto_ccmp.c
  head/sys/net80211/ieee80211_crypto_tkip.c
  head/sys/net80211/ieee80211_crypto_wep.c
  head/sys/net80211/ieee80211_freebsd.c
  head/sys/net80211/ieee80211_hostap.c
  head/sys/net80211/ieee80211_input.c
  head/sys/net80211/ieee80211_ioctl.c
  head/sys/net80211/ieee80211_node.c
  head/sys/net80211/ieee80211_power.c
  head/sys/net80211/ieee80211_proto.c
  head/sys/net80211/ieee80211_scan.c
  head/sys/net80211/ieee80211_scan_sta.c
  head/sys/net80211/ieee80211_sta.c
  head/sys/sys/malloc.h

Modified: head/sys/net80211/ieee80211_acl.c
==============================================================================
--- head/sys/net80211/ieee80211_acl.c	Thu Oct 23 19:16:57 2008	(r184209)
+++ head/sys/net80211/ieee80211_acl.c	Thu Oct 23 19:57:13 2008	(r184210)
@@ -99,7 +99,7 @@ acl_attach(struct ieee80211vap *vap)
 {
 	struct aclstate *as;
 
-	as = malloc(sizeof(struct aclstate),
+	MALLOC(as, struct aclstate *, sizeof(struct aclstate),
 		M_80211_ACL, M_NOWAIT | M_ZERO);
 	if (as == NULL)
 		return 0;
@@ -123,7 +123,7 @@ acl_detach(struct ieee80211vap *vap)
 	acl_free_all(vap);
 	vap->iv_as = NULL;
 	ACL_LOCK_DESTROY(as);
-	free(as, M_80211_ACL);
+	FREE(as, M_80211_ACL);
 }
 
 static __inline struct acl *
@@ -147,7 +147,7 @@ _acl_free(struct aclstate *as, struct ac
 
 	TAILQ_REMOVE(&as->as_list, acl, acl_list);
 	LIST_REMOVE(acl, acl_hash);
-	free(acl, M_80211_ACL);
+	FREE(acl, M_80211_ACL);
 	as->as_nacls--;
 }
 
@@ -175,7 +175,7 @@ acl_add(struct ieee80211vap *vap, const 
 	struct acl *acl, *new;
 	int hash;
 
-	new = malloc(sizeof(struct acl), M_80211_ACL, M_NOWAIT | M_ZERO);
+	MALLOC(new, struct acl *, sizeof(struct acl), M_80211_ACL, M_NOWAIT | M_ZERO);
 	if (new == NULL) {
 		IEEE80211_DPRINTF(vap, IEEE80211_MSG_ACL,
 			"ACL: add %s failed, no memory\n", ether_sprintf(mac));
@@ -188,7 +188,7 @@ acl_add(struct ieee80211vap *vap, const 
 	LIST_FOREACH(acl, &as->as_hash[hash], acl_hash) {
 		if (IEEE80211_ADDR_EQ(acl->acl_macaddr, mac)) {
 			ACL_UNLOCK(as);
-			free(new, M_80211_ACL);
+			FREE(new, M_80211_ACL);
 			IEEE80211_DPRINTF(vap, IEEE80211_MSG_ACL,
 				"ACL: add %s failed, already present\n",
 				ether_sprintf(mac));
@@ -301,7 +301,7 @@ acl_getioctl(struct ieee80211vap *vap, s
 			ireq->i_len = space;	/* return required space */
 			return 0;		/* NB: must not error */
 		}
-		ap = malloc(space,
+		MALLOC(ap, struct ieee80211req_maclist *, space,
 		    M_TEMP, M_NOWAIT);
 		if (ap == NULL)
 			return ENOMEM;
@@ -317,7 +317,7 @@ acl_getioctl(struct ieee80211vap *vap, s
 			ireq->i_len = space;
 		} else
 			error = copyout(ap, ireq->i_data, ireq->i_len);
-		free(ap, M_TEMP);
+		FREE(ap, M_TEMP);
 		return error;
 	}
 	return EINVAL;

Modified: head/sys/net80211/ieee80211_crypto_ccmp.c
==============================================================================
--- head/sys/net80211/ieee80211_crypto_ccmp.c	Thu Oct 23 19:16:57 2008	(r184209)
+++ head/sys/net80211/ieee80211_crypto_ccmp.c	Thu Oct 23 19:57:13 2008	(r184210)
@@ -96,7 +96,7 @@ ccmp_attach(struct ieee80211vap *vap, st
 {
 	struct ccmp_ctx *ctx;
 
-	ctx = malloc(sizeof(struct ccmp_ctx),
+	MALLOC(ctx, struct ccmp_ctx *, sizeof(struct ccmp_ctx),
 		M_80211_CRYPTO, M_NOWAIT | M_ZERO);
 	if (ctx == NULL) {
 		vap->iv_stats.is_crypto_nomem++;
@@ -113,7 +113,7 @@ ccmp_detach(struct ieee80211_key *k)
 {
 	struct ccmp_ctx *ctx = k->wk_private;
 
-	free(ctx, M_80211_CRYPTO);
+	FREE(ctx, M_80211_CRYPTO);
 	KASSERT(nrefs > 0, ("imbalanced attach/detach"));
 	nrefs--;			/* NB: we assume caller locking */
 }

Modified: head/sys/net80211/ieee80211_crypto_tkip.c
==============================================================================
--- head/sys/net80211/ieee80211_crypto_tkip.c	Thu Oct 23 19:16:57 2008	(r184209)
+++ head/sys/net80211/ieee80211_crypto_tkip.c	Thu Oct 23 19:57:13 2008	(r184210)
@@ -109,7 +109,7 @@ tkip_attach(struct ieee80211vap *vap, st
 {
 	struct tkip_ctx *ctx;
 
-	ctx = malloc(sizeof(struct tkip_ctx),
+	MALLOC(ctx, struct tkip_ctx *, sizeof(struct tkip_ctx),
 		M_80211_CRYPTO, M_NOWAIT | M_ZERO);
 	if (ctx == NULL) {
 		vap->iv_stats.is_crypto_nomem++;
@@ -126,7 +126,7 @@ tkip_detach(struct ieee80211_key *k)
 {
 	struct tkip_ctx *ctx = k->wk_private;
 
-	free(ctx, M_80211_CRYPTO);
+	FREE(ctx, M_80211_CRYPTO);
 	KASSERT(nrefs > 0, ("imbalanced attach/detach"));
 	nrefs--;			/* NB: we assume caller locking */
 }

Modified: head/sys/net80211/ieee80211_crypto_wep.c
==============================================================================
--- head/sys/net80211/ieee80211_crypto_wep.c	Thu Oct 23 19:16:57 2008	(r184209)
+++ head/sys/net80211/ieee80211_crypto_wep.c	Thu Oct 23 19:57:13 2008	(r184210)
@@ -87,7 +87,7 @@ wep_attach(struct ieee80211vap *vap, str
 {
 	struct wep_ctx *ctx;
 
-	ctx = malloc(sizeof(struct wep_ctx),
+	MALLOC(ctx, struct wep_ctx *, sizeof(struct wep_ctx),
 		M_80211_CRYPTO, M_NOWAIT | M_ZERO);
 	if (ctx == NULL) {
 		vap->iv_stats.is_crypto_nomem++;
@@ -106,7 +106,7 @@ wep_detach(struct ieee80211_key *k)
 {
 	struct wep_ctx *ctx = k->wk_private;
 
-	free(ctx, M_80211_CRYPTO);
+	FREE(ctx, M_80211_CRYPTO);
 	KASSERT(nrefs > 0, ("imbalanced attach/detach"));
 	nrefs--;			/* NB: we assume caller locking */
 }

Modified: head/sys/net80211/ieee80211_freebsd.c
==============================================================================
--- head/sys/net80211/ieee80211_freebsd.c	Thu Oct 23 19:16:57 2008	(r184209)
+++ head/sys/net80211/ieee80211_freebsd.c	Thu Oct 23 19:57:13 2008	(r184210)
@@ -234,7 +234,7 @@ ieee80211_sysctl_vattach(struct ieee8021
 	struct sysctl_oid *oid;
 	char num[14];			/* sufficient for 32 bits */
 
-	ctx = malloc(sizeof(struct sysctl_ctx_list),
+	MALLOC(ctx, struct sysctl_ctx_list *, sizeof(struct sysctl_ctx_list),
 		M_DEVBUF, M_NOWAIT | M_ZERO);
 	if (ctx == NULL) {
 		if_printf(ifp, "%s: cannot allocate sysctl context!\n",
@@ -310,7 +310,7 @@ ieee80211_sysctl_vdetach(struct ieee8021
 
 	if (vap->iv_sysctl != NULL) {
 		sysctl_ctx_free(vap->iv_sysctl);
-		free(vap->iv_sysctl, M_DEVBUF);
+		FREE(vap->iv_sysctl, M_DEVBUF);
 		vap->iv_sysctl = NULL;
 	}
 }

Modified: head/sys/net80211/ieee80211_hostap.c
==============================================================================
--- head/sys/net80211/ieee80211_hostap.c	Thu Oct 23 19:16:57 2008	(r184209)
+++ head/sys/net80211/ieee80211_hostap.c	Thu Oct 23 19:57:13 2008	(r184210)
@@ -902,7 +902,7 @@ hostap_auth_open(struct ieee80211_node *
 		 * open auth is attempted.
 		 */
 		if (ni->ni_challenge != NULL) {
-			free(ni->ni_challenge, M_80211_NODE);
+			FREE(ni->ni_challenge, M_80211_NODE);
 			ni->ni_challenge = NULL;
 		}
 		/* XXX hack to workaround calling convention */
@@ -1986,7 +1986,7 @@ hostap_recv_mgmt(struct ieee80211_node *
 			return;
 		/* discard challenge after association */
 		if (ni->ni_challenge != NULL) {
-			free(ni->ni_challenge, M_80211_NODE);
+			FREE(ni->ni_challenge, M_80211_NODE);
 			ni->ni_challenge = NULL;
 		}
 		/* NB: 802.11 spec says to ignore station's privacy bit */

Modified: head/sys/net80211/ieee80211_input.c
==============================================================================
--- head/sys/net80211/ieee80211_input.c	Thu Oct 23 19:16:57 2008	(r184209)
+++ head/sys/net80211/ieee80211_input.c	Thu Oct 23 19:57:13 2008	(r184210)
@@ -499,7 +499,7 @@ int
 ieee80211_alloc_challenge(struct ieee80211_node *ni)
 {
 	if (ni->ni_challenge == NULL)
-		ni->ni_challenge = malloc(IEEE80211_CHALLENGE_LEN,
+		MALLOC(ni->ni_challenge, uint32_t*, IEEE80211_CHALLENGE_LEN,
 		    M_80211_NODE, M_NOWAIT);
 	if (ni->ni_challenge == NULL) {
 		IEEE80211_NOTE(ni->ni_vap,

Modified: head/sys/net80211/ieee80211_ioctl.c
==============================================================================
--- head/sys/net80211/ieee80211_ioctl.c	Thu Oct 23 19:16:57 2008	(r184209)
+++ head/sys/net80211/ieee80211_ioctl.c	Thu Oct 23 19:57:13 2008	(r184210)
@@ -320,14 +320,14 @@ ieee80211_ioctl_getscanresults(struct ie
 
 		space = req.space;
 		/* XXX M_WAITOK after driver lock released */
-		p = malloc(space, M_TEMP, M_NOWAIT | M_ZERO);
+		MALLOC(p, void *, space, M_TEMP, M_NOWAIT | M_ZERO);
 		if (p == NULL)
 			return ENOMEM;
 		req.sr = p;
 		ieee80211_scan_iterate(vap, get_scan_result, &req);
 		ireq->i_len = space - req.space;
 		error = copyout(p, ireq->i_data, ireq->i_len);
-		free(p, M_TEMP);
+		FREE(p, M_TEMP);
 	} else
 		ireq->i_len = 0;
 
@@ -467,7 +467,7 @@ getstainfo_common(struct ieee80211vap *v
 	if (req.space > 0) {
 		space = req.space;
 		/* XXX M_WAITOK after driver lock released */
-		p = malloc(space, M_TEMP, M_NOWAIT | M_ZERO);
+		MALLOC(p, void *, space, M_TEMP, M_NOWAIT | M_ZERO);
 		if (p == NULL) {
 			error = ENOMEM;
 			goto bad;
@@ -479,7 +479,7 @@ getstainfo_common(struct ieee80211vap *v
 			get_sta_info(&req, ni);
 		ireq->i_len = space - req.space;
 		error = copyout(p, (uint8_t *) ireq->i_data+off, ireq->i_len);
-		free(p, M_TEMP);
+		FREE(p, M_TEMP);
 	} else
 		ireq->i_len = 0;
 bad:
@@ -696,7 +696,8 @@ ieee80211_ioctl_getdevcaps(struct ieee80
 
 	if (ireq->i_len != sizeof(struct ieee80211_devcaps_req))
 		return EINVAL;
-	dc = malloc(	    sizeof(struct ieee80211_devcaps_req), M_TEMP, M_NOWAIT | M_ZERO);
+	MALLOC(dc, struct ieee80211_devcaps_req *,
+	    sizeof(struct ieee80211_devcaps_req), M_TEMP, M_NOWAIT | M_ZERO);
 	if (dc == NULL)
 		return ENOMEM;
 	dc->dc_drivercaps = ic->ic_caps;
@@ -706,7 +707,7 @@ ieee80211_ioctl_getdevcaps(struct ieee80
 	ic->ic_getradiocaps(ic, &ci->ic_nchans, ci->ic_chans);
 	ieee80211_sort_channels(ci->ic_chans, ci->ic_nchans);
 	error = copyout(dc, ireq->i_data, sizeof(*dc));
-	free(dc, M_TEMP);
+	FREE(dc, M_TEMP);
 	return error;
 }
 
@@ -1992,13 +1993,14 @@ ieee80211_ioctl_setregdomain(struct ieee
 
 	if (ireq->i_len != sizeof(struct ieee80211_regdomain_req))
 		return EINVAL;
-	reg = malloc(	    sizeof(struct ieee80211_regdomain_req), M_TEMP, M_NOWAIT);
+	MALLOC(reg, struct ieee80211_regdomain_req *,
+	    sizeof(struct ieee80211_regdomain_req), M_TEMP, M_NOWAIT);
 	if (reg == NULL)
 		return ENOMEM;
 	error = copyin(ireq->i_data, reg, sizeof(*reg));
 	if (error == 0)
 		error = ieee80211_setregdomain(vap, reg);
-	free(reg, M_TEMP);
+	FREE(reg, M_TEMP);
 
 	return (error == 0 ? ENETRESET : error);
 }
@@ -2137,7 +2139,7 @@ setappie(struct ieee80211_appie **aie, c
 	if (ireq->i_len == 0) {		/* delete any existing ie */
 		if (app != NULL) {
 			*aie = NULL;	/* XXX racey */
-			free(app, M_80211_NODE_IE);
+			FREE(app, M_80211_NODE_IE);
 		}
 		return 0;
 	}
@@ -2151,19 +2153,20 @@ setappie(struct ieee80211_appie **aie, c
 	 *
 	 * XXX bad bad bad
 	 */
-	napp = malloc(	    sizeof(struct ieee80211_appie) + ireq->i_len, M_80211_NODE_IE, M_NOWAIT);
+	MALLOC(napp, struct ieee80211_appie *,
+	    sizeof(struct ieee80211_appie) + ireq->i_len, M_80211_NODE_IE, M_NOWAIT);
 	if (napp == NULL)
 		return ENOMEM;
 	/* XXX holding ic lock */
 	error = copyin(ireq->i_data, napp->ie_data, ireq->i_len);
 	if (error) {
-		free(napp, M_80211_NODE_IE);
+		FREE(napp, M_80211_NODE_IE);
 		return error;
 	}
 	napp->ie_len = ireq->i_len;
 	*aie = napp;
 	if (app != NULL)
-		free(app, M_80211_NODE_IE);
+		FREE(app, M_80211_NODE_IE);
 	return 0;
 }
 

Modified: head/sys/net80211/ieee80211_node.c
==============================================================================
--- head/sys/net80211/ieee80211_node.c	Thu Oct 23 19:16:57 2008	(r184209)
+++ head/sys/net80211/ieee80211_node.c	Thu Oct 23 19:57:13 2008	(r184210)
@@ -148,7 +148,8 @@ ieee80211_node_latevattach(struct ieee80
 			    "WARNING: max aid too small, changed to %d\n",
 			    vap->iv_max_aid);
 		}
-		vap->iv_aid_bitmap = malloc(			howmany(vap->iv_max_aid, 32) * sizeof(uint32_t),
+		MALLOC(vap->iv_aid_bitmap, uint32_t *,
+			howmany(vap->iv_max_aid, 32) * sizeof(uint32_t),
 			M_80211_NODE, M_NOWAIT | M_ZERO);
 		if (vap->iv_aid_bitmap == NULL) {
 			/* XXX no way to recover */
@@ -174,7 +175,7 @@ ieee80211_node_vdetach(struct ieee80211v
 		vap->iv_bss = NULL;
 	}
 	if (vap->iv_aid_bitmap != NULL) {
-		free(vap->iv_aid_bitmap, M_80211_NODE);
+		FREE(vap->iv_aid_bitmap, M_80211_NODE);
 		vap->iv_aid_bitmap = NULL;
 	}
 }
@@ -768,7 +769,7 @@ node_alloc(struct ieee80211vap *vap, con
 {
 	struct ieee80211_node *ni;
 
-	ni = malloc(sizeof(struct ieee80211_node),
+	MALLOC(ni, struct ieee80211_node *, sizeof(struct ieee80211_node),
 		M_80211_NODE, M_NOWAIT | M_ZERO);
 	return ni;
 }
@@ -786,11 +787,11 @@ ieee80211_ies_init(struct ieee80211_ies 
 	memset(ies, 0, offsetof(struct ieee80211_ies, data));
 	if (ies->data != NULL && ies->len != len) {
 		/* data size changed */
-		free(ies->data, M_80211_NODE_IE);
+		FREE(ies->data, M_80211_NODE_IE);
 		ies->data = NULL;
 	}
 	if (ies->data == NULL) {
-		ies->data = malloc(len, M_80211_NODE_IE, M_NOWAIT);
+		MALLOC(ies->data, uint8_t *, len, M_80211_NODE_IE, M_NOWAIT);
 		if (ies->data == NULL) {
 			ies->len = 0;
 			/* NB: pointers have already been zero'd above */
@@ -809,7 +810,7 @@ void
 ieee80211_ies_cleanup(struct ieee80211_ies *ies)
 {
 	if (ies->data != NULL)
-		free(ies->data, M_80211_NODE_IE);
+		FREE(ies->data, M_80211_NODE_IE);
 }
 
 /*
@@ -889,7 +890,7 @@ node_cleanup(struct ieee80211_node *ni)
 
 	ni->ni_associd = 0;
 	if (ni->ni_challenge != NULL) {
-		free(ni->ni_challenge, M_80211_NODE);
+		FREE(ni->ni_challenge, M_80211_NODE);
 		ni->ni_challenge = NULL;
 	}
 	/*
@@ -925,7 +926,7 @@ node_free(struct ieee80211_node *ni)
 	ieee80211_ies_cleanup(&ni->ni_ies);
 	IEEE80211_NODE_SAVEQ_DESTROY(ni);
 	IEEE80211_NODE_WDSQ_DESTROY(ni);
-	free(ni, M_80211_NODE);
+	FREE(ni, M_80211_NODE);
 }
 
 static void
@@ -1777,7 +1778,8 @@ ieee80211_node_table_init(struct ieee802
 	nt->nt_inact_init = inact;
 	nt->nt_keyixmax = keyixmax;
 	if (nt->nt_keyixmax > 0) {
-		nt->nt_keyixmap = malloc(			keyixmax * sizeof(struct ieee80211_node *),
+		MALLOC(nt->nt_keyixmap, struct ieee80211_node **,
+			keyixmax * sizeof(struct ieee80211_node *),
 			M_80211_NODE, M_NOWAIT | M_ZERO);
 		if (nt->nt_keyixmap == NULL)
 			if_printf(ic->ic_ifp,
@@ -1837,7 +1839,7 @@ ieee80211_node_table_cleanup(struct ieee
 				printf("%s: %s[%u] still active\n", __func__,
 					nt->nt_name, i);
 #endif
-		free(nt->nt_keyixmap, M_80211_NODE);
+		FREE(nt->nt_keyixmap, M_80211_NODE);
 		nt->nt_keyixmap = NULL;
 	}
 	IEEE80211_NODE_ITERATE_LOCK_DESTROY(nt);

Modified: head/sys/net80211/ieee80211_power.c
==============================================================================
--- head/sys/net80211/ieee80211_power.c	Thu Oct 23 19:16:57 2008	(r184209)
+++ head/sys/net80211/ieee80211_power.c	Thu Oct 23 19:57:13 2008	(r184210)
@@ -80,7 +80,7 @@ ieee80211_power_latevattach(struct ieee8
 	 */
 	if (vap->iv_opmode == IEEE80211_M_HOSTAP) {
 		vap->iv_tim_len = howmany(vap->iv_max_aid,8) * sizeof(uint8_t);
-		vap->iv_tim_bitmap = malloc(vap->iv_tim_len,
+		MALLOC(vap->iv_tim_bitmap, uint8_t *, vap->iv_tim_len,
 			M_80211_POWER, M_NOWAIT | M_ZERO);
 		if (vap->iv_tim_bitmap == NULL) {
 			printf("%s: no memory for TIM bitmap!\n", __func__);
@@ -94,7 +94,7 @@ void
 ieee80211_power_vdetach(struct ieee80211vap *vap)
 {
 	if (vap->iv_tim_bitmap != NULL) {
-		free(vap->iv_tim_bitmap, M_80211_POWER);
+		FREE(vap->iv_tim_bitmap, M_80211_POWER);
 		vap->iv_tim_bitmap = NULL;
 	}
 }

Modified: head/sys/net80211/ieee80211_proto.c
==============================================================================
--- head/sys/net80211/ieee80211_proto.c	Thu Oct 23 19:16:57 2008	(r184209)
+++ head/sys/net80211/ieee80211_proto.c	Thu Oct 23 19:57:13 2008	(r184210)
@@ -214,7 +214,7 @@ ieee80211_proto_vdetach(struct ieee80211
 {
 #define	FREEAPPIE(ie) do { \
 	if (ie != NULL) \
-		free(ie, M_80211_NODE_IE); \
+		FREE(ie, M_80211_NODE_IE); \
 } while (0)
 	/*
 	 * Detach operating mode module.

Modified: head/sys/net80211/ieee80211_scan.c
==============================================================================
--- head/sys/net80211/ieee80211_scan.c	Thu Oct 23 19:16:57 2008	(r184209)
+++ head/sys/net80211/ieee80211_scan.c	Thu Oct 23 19:57:13 2008	(r184210)
@@ -96,7 +96,7 @@ ieee80211_scan_attach(struct ieee80211co
 {
 	struct scan_state *ss;
 
-	ss = malloc(sizeof(struct scan_state),
+	MALLOC(ss, struct scan_state *, sizeof(struct scan_state),
 		M_80211_SCAN, M_NOWAIT | M_ZERO);
 	if (ss == NULL) {
 		ic->ic_scan = NULL;
@@ -122,7 +122,7 @@ ieee80211_scan_detach(struct ieee80211co
 		}
 		ic->ic_flags &= ~IEEE80211_F_SCAN;
 		ic->ic_scan = NULL;
-		free(SCAN_PRIVATE(ss), M_80211_SCAN);
+		FREE(SCAN_PRIVATE(ss), M_80211_SCAN);
 	}
 }
 

Modified: head/sys/net80211/ieee80211_scan_sta.c
==============================================================================
--- head/sys/net80211/ieee80211_scan_sta.c	Thu Oct 23 19:16:57 2008	(r184209)
+++ head/sys/net80211/ieee80211_scan_sta.c	Thu Oct 23 19:57:13 2008	(r184210)
@@ -138,7 +138,7 @@ sta_attach(struct ieee80211_scan_state *
 {
 	struct sta_table *st;
 
-	st = malloc(sizeof(struct sta_table),
+	MALLOC(st, struct sta_table *, sizeof(struct sta_table),
 		M_80211_SCAN, M_NOWAIT | M_ZERO);
 	if (st == NULL)
 		return 0;
@@ -162,7 +162,7 @@ sta_detach(struct ieee80211_scan_state *
 		sta_flush_table(st);
 		mtx_destroy(&st->st_lock);
 		mtx_destroy(&st->st_scanlock);
-		free(st, M_80211_SCAN);
+		FREE(st, M_80211_SCAN);
 		KASSERT(nrefs > 0, ("imbalanced attach/detach"));
 		nrefs--;		/* NB: we assume caller locking */
 	}
@@ -196,7 +196,7 @@ sta_flush_table(struct sta_table *st)
 		TAILQ_REMOVE(&st->st_entry, se, se_list);
 		LIST_REMOVE(se, se_hash);
 		ieee80211_ies_cleanup(&se->base.se_ies);
-		free(se, M_80211_SCAN);
+		FREE(se, M_80211_SCAN);
 	}
 	memset(st->st_maxrssi, 0, sizeof(st->st_maxrssi));
 }
@@ -229,7 +229,7 @@ sta_add(struct ieee80211_scan_state *ss,
 	LIST_FOREACH(se, &st->st_hash[hash], se_hash)
 		if (IEEE80211_ADDR_EQ(se->base.se_macaddr, macaddr))
 			goto found;
-	se = malloc(sizeof(struct sta_entry),
+	MALLOC(se, struct sta_entry *, sizeof(struct sta_entry),
 		M_80211_SCAN, M_NOWAIT | M_ZERO);
 	if (se == NULL) {
 		mtx_unlock(&st->st_lock);
@@ -1439,7 +1439,7 @@ adhoc_age(struct ieee80211_scan_state *s
 			TAILQ_REMOVE(&st->st_entry, se, se_list);
 			LIST_REMOVE(se, se_hash);
 			ieee80211_ies_cleanup(&se->base.se_ies);
-			free(se, M_80211_SCAN);
+			FREE(se, M_80211_SCAN);
 		}
 	}
 	mtx_unlock(&st->st_lock);

Modified: head/sys/net80211/ieee80211_sta.c
==============================================================================
--- head/sys/net80211/ieee80211_sta.c	Thu Oct 23 19:16:57 2008	(r184209)
+++ head/sys/net80211/ieee80211_sta.c	Thu Oct 23 19:57:13 2008	(r184210)
@@ -1013,7 +1013,7 @@ sta_auth_shared(struct ieee80211_node *n
 	switch (seq) {
 	case IEEE80211_AUTH_SHARED_PASS:
 		if (ni->ni_challenge != NULL) {
-			free(ni->ni_challenge, M_80211_NODE);
+			FREE(ni->ni_challenge, M_80211_NODE);
 			ni->ni_challenge = NULL;
 		}
 		if (status != 0) {

Modified: head/sys/sys/malloc.h
==============================================================================
--- head/sys/sys/malloc.h	Thu Oct 23 19:16:57 2008	(r184209)
+++ head/sys/sys/malloc.h	Thu Oct 23 19:57:13 2008	(r184210)
@@ -167,6 +167,13 @@ MALLOC_DECLARE(M_IP6OPT); /* for INET6 *
 MALLOC_DECLARE(M_IP6NDP); /* for INET6 */
 
 /*
+ * Deprecated macro versions of not-quite-malloc() and free().
+ */
+#define	MALLOC(space, cast, size, type, flags) \
+	((space) = (cast)malloc((u_long)(size), (type), (flags)))
+#define	FREE(addr, type) free((addr), (type))
+
+/*
  * XXX this should be declared in <sys/uio.h>, but that tends to fail
  * because <sys/uio.h> is included in a header before the source file
  * has a chance to include <sys/malloc.h> to get MALLOC_DECLARE() defined.


More information about the svn-src-head mailing list