Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Dec 2012 16:11:13 +0000 (UTC)
From:      Monthadar Al Jaberi <monthadar@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r244399 - head/sys/dev/wtap
Message-ID:  <201212181611.qBIGBDIT079705@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: monthadar
Date: Tue Dec 18 16:11:13 2012
New Revision: 244399
URL: http://svnweb.freebsd.org/changeset/base/244399

Log:
  wtap fix malloc/free.
  
  * Remove malloc/free pointer cast;
  * Check return value from malloc;
  
  Submitted by: glebius
  Approved by: adrian (mentor)

Modified:
  head/sys/dev/wtap/if_wtap.c

Modified: head/sys/dev/wtap/if_wtap.c
==============================================================================
--- head/sys/dev/wtap/if_wtap.c	Tue Dec 18 14:32:53 2012	(r244398)
+++ head/sys/dev/wtap/if_wtap.c	Tue Dec 18 16:11:13 2012	(r244399)
@@ -326,8 +326,9 @@ wtap_vap_create(struct ieee80211com *ic,
 
 	 DWTAP_PRINTF("%s\n", __func__);
 
-	avp = (struct wtap_vap *) malloc(sizeof(struct wtap_vap),
-	    M_80211_VAP, M_NOWAIT | M_ZERO);
+	avp = malloc(sizeof(struct wtap_vap), M_80211_VAP, M_NOWAIT | M_ZERO);
+	if (avp == NULL)
+		return (NULL);
 	avp->id = sc->id;
 	avp->av_md = sc->sc_md;
 	avp->av_bcinterval = msecs_to_ticks(BEACON_INTRERVAL + 100*sc->id);
@@ -335,8 +336,8 @@ wtap_vap_create(struct ieee80211com *ic,
 	error = ieee80211_vap_setup(ic, vap, name, unit, IEEE80211_M_MBSS,
 	    flags | IEEE80211_CLONE_NOBEACONS, bssid, mac);
 	if (error) {
-		free((struct wtap_vap*) vap, M_80211_VAP);
-		return NULL;
+		free(avp, M_80211_VAP);
+		return (NULL);
 	}
 
 	/* override various methods */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212181611.qBIGBDIT079705>