Date: Wed, 14 May 2014 15:52:37 +0000 (UTC) From: Marius Strobl <marius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r266041 - stable/8/sbin/gvinum Message-ID: <201405141552.s4EFqbwc005876@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marius Date: Wed May 14 15:52:36 2014 New Revision: 266041 URL: http://svnweb.freebsd.org/changeset/base/266041 Log: MFC: r256561 Prevent an unlikely, but real double free issue in gvinum(8). Coverity ID: 1018965 Modified: stable/8/sbin/gvinum/gvinum.c Directory Properties: stable/8/sbin/gvinum/ (props changed) Modified: stable/8/sbin/gvinum/gvinum.c ============================================================================== --- stable/8/sbin/gvinum/gvinum.c Wed May 14 15:52:26 2014 (r266040) +++ stable/8/sbin/gvinum/gvinum.c Wed May 14 15:52:36 2014 (r266041) @@ -421,6 +421,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; @@ -448,10 +449,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. */ @@ -461,14 +460,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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405141552.s4EFqbwc005876>