summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2014-05-14 16:16:23 +0000
committermarius <marius@FreeBSD.org>2014-05-14 16:16:23 +0000
commit10d4c26464e17dfbadfd211f3d91b27c45d692d8 (patch)
tree0126dfa8a8e1be9ca78c11dbc7ffe4ea3356d78a /sbin
parent21b23c5efbabe97bf676237710d61dfc9f99e8ed (diff)
downloadFreeBSD-src-10d4c26464e17dfbadfd211f3d91b27c45d692d8.zip
FreeBSD-src-10d4c26464e17dfbadfd211f3d91b27c45d692d8.tar.gz
MFC: r256561
Prevent an unlikely, but real double free issue in gvinum(8). Coverity ID: 1018965
Diffstat (limited to 'sbin')
-rw-r--r--sbin/gvinum/gvinum.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/sbin/gvinum/gvinum.c b/sbin/gvinum/gvinum.c
index 31974a9..278a268 100644
--- a/sbin/gvinum/gvinum.c
+++ b/sbin/gvinum/gvinum.c
@@ -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);
OpenPOWER on IntegriCloud