From owner-svn-src-all@FreeBSD.ORG Wed May 14 16:16:23 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9FEAB5C8; Wed, 14 May 2014 16:16:23 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8C6D22F7A; Wed, 14 May 2014 16:16:23 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4EGGNMJ015738; Wed, 14 May 2014 16:16:23 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4EGGNot015737; Wed, 14 May 2014 16:16:23 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201405141616.s4EGGNot015737@svn.freebsd.org> From: Marius Strobl Date: Wed, 14 May 2014 16:16:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r266042 - stable/10/sbin/gvinum X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 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: Wed, 14 May 2014 16:16:23 -0000 Author: marius Date: Wed May 14 16:16:23 2014 New Revision: 266042 URL: http://svnweb.freebsd.org/changeset/base/266042 Log: MFC: r256561 Prevent an unlikely, but real double free issue in gvinum(8). Coverity ID: 1018965 Modified: stable/10/sbin/gvinum/gvinum.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/gvinum/gvinum.c ============================================================================== --- stable/10/sbin/gvinum/gvinum.c Wed May 14 15:52:36 2014 (r266041) +++ stable/10/sbin/gvinum/gvinum.c Wed May 14 16:16:23 2014 (r266042) @@ -423,6 +423,7 @@ create_drive(char *device) const char *errstr; char *drivename, *dname; int drives, i, flags, volumes, subdisks, plexes; + int found = 0; flags = plexes = subdisks = volumes = 0; drives = 1; @@ -450,10 +451,8 @@ create_drive(char *device) errstr = gctl_issue(req); if (errstr != NULL) { warnx("error creating drive: %s", errstr); - gctl_free(req); - return (NULL); + drivename = NULL; } else { - gctl_free(req); /* XXX: This is needed because we have to make sure the drives * are created before we return. */ /* Loop until it's in the config. */ @@ -463,14 +462,18 @@ create_drive(char *device) /* If we got a different name, quit. */ if (dname == NULL) continue; - if (strcmp(dname, drivename)) { - free(dname); - return (drivename); - } + if (strcmp(dname, drivename)) + found = 1; free(dname); dname = NULL; + if (found) + break; usleep(100000); /* Sleep for 0.1s */ } + if (found == 0) { + warnx("error creating drive"); + drivename = NULL; + } } gctl_free(req); return (drivename);