Avoid accessing an uninitialized variable when vfork() fails.

Reported by:	Miles Ohlrich <miles.ohlrich@isilon.com>
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
This commit is contained in:
markj 2017-03-22 18:31:44 +00:00
parent dddc1b0c57
commit fed351d4f4

View File

@ -178,8 +178,7 @@ proc_create(const char *file, char * const *argv, proc_child_func *pcf,
void *child_arg, struct proc_handle **pphdl) void *child_arg, struct proc_handle **pphdl)
{ {
struct proc_handle *phdl; struct proc_handle *phdl;
int error = 0; int error, status;
int status;
pid_t pid; pid_t pid;
if (elf_version(EV_CURRENT) == EV_NONE) if (elf_version(EV_CURRENT) == EV_NONE)
@ -217,16 +216,17 @@ proc_create(const char *file, char * const *argv, proc_child_func *pcf,
/* Check for an unexpected status. */ /* Check for an unexpected status. */
if (!WIFSTOPPED(status)) { if (!WIFSTOPPED(status)) {
error = errno; error = EBUSY;
DPRINTFX("ERROR: child process %d status 0x%x", pid, status); DPRINTFX("ERROR: child process %d status 0x%x", pid, status);
goto bad; goto bad;
} else }
phdl->status = PS_STOP; phdl->status = PS_STOP;
}
bad: bad:
if (error && phdl != NULL) { if (error != 0 && phdl != NULL) {
proc_free(phdl); proc_free(phdl);
phdl = NULL; phdl = NULL;
}
} }
*pphdl = phdl; *pphdl = phdl;
return (error); return (error);