mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-04 18:59:37 +00:00
Prevent an unlikely, but real double free issue in gvinum(8).
Coverity ID: 1018965
This commit is contained in:
parent
5532d94759
commit
b9099489a8
@ -421,6 +421,7 @@ create_drive(char *device)
|
|||||||
const char *errstr;
|
const char *errstr;
|
||||||
char *drivename, *dname;
|
char *drivename, *dname;
|
||||||
int drives, i, flags, volumes, subdisks, plexes;
|
int drives, i, flags, volumes, subdisks, plexes;
|
||||||
|
int found = 0;
|
||||||
|
|
||||||
flags = plexes = subdisks = volumes = 0;
|
flags = plexes = subdisks = volumes = 0;
|
||||||
drives = 1;
|
drives = 1;
|
||||||
@ -448,10 +449,8 @@ create_drive(char *device)
|
|||||||
errstr = gctl_issue(req);
|
errstr = gctl_issue(req);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
warnx("error creating drive: %s", errstr);
|
warnx("error creating drive: %s", errstr);
|
||||||
gctl_free(req);
|
drivename = NULL;
|
||||||
return (NULL);
|
|
||||||
} else {
|
} else {
|
||||||
gctl_free(req);
|
|
||||||
/* XXX: This is needed because we have to make sure the drives
|
/* XXX: This is needed because we have to make sure the drives
|
||||||
* are created before we return. */
|
* are created before we return. */
|
||||||
/* Loop until it's in the config. */
|
/* Loop until it's in the config. */
|
||||||
@ -461,14 +460,18 @@ create_drive(char *device)
|
|||||||
/* If we got a different name, quit. */
|
/* If we got a different name, quit. */
|
||||||
if (dname == NULL)
|
if (dname == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (strcmp(dname, drivename)) {
|
if (strcmp(dname, drivename))
|
||||||
free(dname);
|
found = 1;
|
||||||
return (drivename);
|
|
||||||
}
|
|
||||||
free(dname);
|
free(dname);
|
||||||
dname = NULL;
|
dname = NULL;
|
||||||
|
if (found)
|
||||||
|
break;
|
||||||
usleep(100000); /* Sleep for 0.1s */
|
usleep(100000); /* Sleep for 0.1s */
|
||||||
}
|
}
|
||||||
|
if (found == 0) {
|
||||||
|
warnx("error creating drive");
|
||||||
|
drivename = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
gctl_free(req);
|
gctl_free(req);
|
||||||
return (drivename);
|
return (drivename);
|
||||||
|
Loading…
Reference in New Issue
Block a user