From owner-svn-src-all@FreeBSD.ORG Tue Dec 18 11:30:55 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7406E53A; Tue, 18 Dec 2012 11:30:55 +0000 (UTC) (envelope-from monthadar@gmail.com) Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 599FF8FC15; Tue, 18 Dec 2012 11:30:54 +0000 (UTC) Received: by mail-we0-f182.google.com with SMTP id u54so241148wey.13 for ; Tue, 18 Dec 2012 03:30:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Nr1VNdXAjRpcrBbPQcKUc3+pGBW9Y8pa/BNOY+W1f28=; b=uQba1VbA2PaJUYHwB2S5cnAuSyh45wg6G4fu+aCK5gV18g8vKhD5dmftUj7P/gClMg Q5oDsrcu7UvWbf4pANmM+nVhreB7R/p7hD5rr0f9EGqvyH12YL5Ned08xXpwKf/g5Z1g wTY/iO1rLqetZEY7j8lFjDYwn88Ioan1pZ0ZlrRwrkCQs86MdVKn91z48dPXRvwCrzIX 95ma3vnHmpVUd8FMqKunWzL5ATwAq2VvjVOilksHBLex2nq1a+chL/nV10wYKuqugmvh zzW/5o+4OTy/WpVqetsmsJ2U7Br7t/XAUkT75c2NxKThvTXbiaPnvAvjumbfbhnvki2W b9gQ== MIME-Version: 1.0 Received: by 10.180.97.68 with SMTP id dy4mr3576959wib.7.1355830253188; Tue, 18 Dec 2012 03:30:53 -0800 (PST) Received: by 10.227.59.19 with HTTP; Tue, 18 Dec 2012 03:30:53 -0800 (PST) In-Reply-To: <20121218085306.GK94420@FreeBSD.org> References: <201212180844.qBI8ixdX097633@svn.freebsd.org> <20121218085306.GK94420@FreeBSD.org> Date: Tue, 18 Dec 2012 12:30:53 +0100 Message-ID: Subject: Re: svn commit: r244389 - head/sys/dev/wtap From: Monthadar Al Jaberi To: Gleb Smirnoff Content-Type: text/plain; charset=ISO-8859-1 Cc: Monthadar Al Jaberi , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Dec 2012 11:30:55 -0000 On Tue, Dec 18, 2012 at 9:53 AM, Gleb Smirnoff wrote: > 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. Thank you for the patch, I can commit it for you, if you havn't done it yet? br, > > -- > Totus tuus, Glebius. -- Monthadar Al Jaberi