svn commit: r244389 - head/sys/dev/wtap

Gleb Smirnoff glebius at FreeBSD.org
Tue Dec 18 08:53:08 UTC 2012


  Monthadar,

On Tue, Dec 18, 2012 at 08:44:59AM +0000, Monthadar Al Jaberi wrote:
M> Author: monthadar
M> Date: Tue Dec 18 08:44:59 2012
M> New Revision: 244389
M> URL: http://svnweb.freebsd.org/changeset/base/244389
M> 
M> Log:
M>   wtap should check if ieee80211_vap_setup fails.
M>   
M>   * If ieee80211_vap_setup fails, we free allocated M_80211_VAP
M>     memory and return NULL;
M>   
M>   Approved by: adrian (mentor)
M> 
M> Modified:
M>   head/sys/dev/wtap/if_wtap.c
M> 
M> Modified: head/sys/dev/wtap/if_wtap.c
M> ==============================================================================
M> --- head/sys/dev/wtap/if_wtap.c	Tue Dec 18 08:41:23 2012	(r244388)
M> +++ head/sys/dev/wtap/if_wtap.c	Tue Dec 18 08:44:59 2012	(r244389)
M> @@ -334,6 +334,10 @@ wtap_vap_create(struct ieee80211com *ic,
M>  	vap = (struct ieee80211vap *) avp;
M>  	error = ieee80211_vap_setup(ic, vap, name, unit, IEEE80211_M_MBSS,
M>  	    flags | IEEE80211_CLONE_NOBEACONS, bssid, mac);
M> +	if (error) {
M> +		free((struct wtap_vap*) vap, M_80211_VAP);
M> +		return NULL;
M> +	}
M>  
M>  	/* override various methods */
M>  	avp->av_recv_mgmt = vap->iv_recv_mgmt;

You don't need to cast first argument of free(9). And you don't need a cast
before malloc(9) as well.

If you are calling malloc(9) with M_NOWAIT, you need to check return result.

Also, more stylish would be to supply to free() the same variable that was
assigned at malloc(9) call, in this particular case it is "avp".

Patch attached.

-- 
Totus tuus, Glebius.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: if_wtap.c.diff
Type: text/x-diff
Size: 834 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20121218/18b1f622/attachment.diff>


More information about the svn-src-head mailing list