From owner-svn-src-all@freebsd.org Fri May 25 15:24:12 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 64102EEA94A; Fri, 25 May 2018 15:24:12 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C48FA85856; Fri, 25 May 2018 15:24:11 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: by mail-wm0-x242.google.com with SMTP id f8-v6so15645982wmc.4; Fri, 25 May 2018 08:24:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=5XTbcLzwkU7BSJ5rL465AxsGYq238dtS060OLKxT2oc=; b=cPdLFeYeK4tHJxPw70iLMiXci8v+fUa5HqPrw6dAsnLSqv5HEEaD+tPqR73N6G8SfL uTp0f6RM5TZX4xIdyDOIwZAsn/WoWNNN1AIn8ahQE82bemHlISqNXLHIAz7Zz4gdoUBH +dvBV7uEZe27UxBJxvmzBgFCj/YtFVyXA/JzIHspeq9yTrPJxBWx8v+xjt5qwW+kVCya aYwFtlkD/s8IXGMWF1UdaK4/IPmgc0tZrm0IyuTAYbMpNqzQmGKJPSVxQ3t2sHNbkgJW S6XuJHp234h28Zu0Z43xKOyTFneFOov/sYq449QH2KSCSfsRxVfyYA6NsKMfEbBSN78r jRLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=5XTbcLzwkU7BSJ5rL465AxsGYq238dtS060OLKxT2oc=; b=hbJC5UwIvdkWMvA/xfrE2g6ZWxVm6xPU5r3KtmVGqnDk435lI7V3RTZLNFMbQBw+64 ewUaAW2HY1x7w7rg/igBL712nY8S4mf9oIqwTDVTan+41L5eVNKiuSYnr/cnImhpKM3h gw2eVm98yp/LuJD518n5e2Bth5HwKF31AbcQKTorQk33GmKeaywoCzfjcW0am5xbC3fj Nh1TU/pHQsqSOjYhvAGOEQXPIzlymsne2aecTJu4tspaXx8bbiDO348bT3QcPDsvcp6g c3OecGusagSrxAGe/ey/tjKQQ9h08SfKSAaCodguPmX29BZ2V1+a8ivmzeaiR6/QyVuN BCgg== X-Gm-Message-State: ALKqPwdEaXo1m78m/GUwF86GcFBzOkc3XqgHEZaWGkWysLOLm0Md3wjs FQFW51AqkyhIJQuG6+xVDRBsaXqWylMX7LG0BIk= X-Google-Smtp-Source: ADUXVKKxwN8YDvIQ8abnfj5ZrLePZGa1ecWfH+QKKOvtVWG8gr703RtTkBPMLzvzb00KA96O94ae4eZjxEWPVJo6mwU= X-Received: by 2002:a2e:c41:: with SMTP id o1-v6mr2059962ljd.87.1527261850553; Fri, 25 May 2018 08:24:10 -0700 (PDT) MIME-Version: 1.0 References: <201805250207.w4P275Pf060725@repo.freebsd.org> <20180525151134.GB99063@spindle.one-eyed-alien.net> In-Reply-To: <20180525151134.GB99063@spindle.one-eyed-alien.net> Reply-To: araujo@freebsd.org From: Marcelo Araujo Date: Fri, 25 May 2018 23:23:59 +0800 Message-ID: Subject: Re: svn commit: r334199 - head/usr.sbin/bhyve To: Brooks Davis Cc: Marcelo Araujo , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.26 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 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: Fri, 25 May 2018 15:24:12 -0000 On Fri, May 25, 2018, 11:11 PM Brooks Davis wrote: > On Fri, May 25, 2018 at 02:07:05AM +0000, Marcelo Araujo wrote: > > Author: araujo > > Date: Fri May 25 02:07:05 2018 > > New Revision: 334199 > > URL: https://svnweb.freebsd.org/changeset/base/334199 > > > > Log: > > Fix a memory leak on topology_parse(). > > > > strdup(3) allocates memory for a copy of the string, does the copy and > > returns a pointer to it. If there is no sufficient memory NULL is > returned > > and the global errno is set to ENOMEM. > > We do a sanity check to see if it was possible to allocate enough > memory. > > > > Also as we allocate memory, we need to free this memory used. Or it > will > > going out of scope leaks the storage it points to. > > > > Reviewed by: rgrimes > > MFC after: 3 weeks. > > X-MFC: r332298 > > Sponsored by: iXsystems Inc. > > Differential Revision: https://reviews.freebsd.org/D15550 > > > > Modified: > > head/usr.sbin/bhyve/bhyverun.c > > > > Modified: head/usr.sbin/bhyve/bhyverun.c > > > ============================================================================== > > --- head/usr.sbin/bhyve/bhyverun.c Fri May 25 01:38:59 2018 > (r334198) > > +++ head/usr.sbin/bhyve/bhyverun.c Fri May 25 02:07:05 2018 > (r334199) > > @@ -193,6 +193,7 @@ topology_parse(const char *opt) > > c = 1, n = 1, s = 1, t = 1; > > ns = false, scts = false; > > str = strdup(opt); > > + assert(str != NULL); > > Using assert seems like an odd choice when you've already added a > failure path and the strsep will crash immediately if assert is elided. > Just to make a better point, I had the same discussion about assert(3) in another review, we don't do NDEBUG even for RELEASE. > > -- Brooks >