diff options
author | Xin LI <delphij@FreeBSD.org> | 2013-10-15 21:04:46 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2013-10-15 21:04:46 +0000 |
commit | 202038ae05f0633b8529f1d69afb6abef7d14634 (patch) | |
tree | 4cc87daabfa4c4c8b252f9e4009a564b35d2540a /sbin | |
parent | 876a7cf40c6e959a2f6e59be4caa26cc2ad5009a (diff) | |
download | src-202038ae05f0633b8529f1d69afb6abef7d14634.tar.gz src-202038ae05f0633b8529f1d69afb6abef7d14634.zip |
Prevent an unlikely, but real double free issue in gvinum(8).
Coverity ID: 1018965
Notes
Notes:
svn path=/head/; revision=256561
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/gvinum/gvinum.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/sbin/gvinum/gvinum.c b/sbin/gvinum/gvinum.c index bb4b47d05116..5760d2b8bb28 100644 --- a/sbin/gvinum/gvinum.c +++ b/sbin/gvinum/gvinum.c @@ -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); |