mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-17 18:11:00 +03:00
zpool: vdev_run_cmd(): don't free undefined pointers
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #11993
This commit is contained in:
parent
12ed5275d1
commit
214ae461f1
@ -494,19 +494,25 @@ vdev_run_cmd(vdev_cmd_data_t *data, char *cmd)
|
|||||||
/* Setup our custom environment variables */
|
/* Setup our custom environment variables */
|
||||||
rc = asprintf(&env[1], "VDEV_PATH=%s",
|
rc = asprintf(&env[1], "VDEV_PATH=%s",
|
||||||
data->path ? data->path : "");
|
data->path ? data->path : "");
|
||||||
if (rc == -1)
|
if (rc == -1) {
|
||||||
|
env[1] = NULL;
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
rc = asprintf(&env[2], "VDEV_UPATH=%s",
|
rc = asprintf(&env[2], "VDEV_UPATH=%s",
|
||||||
data->upath ? data->upath : "");
|
data->upath ? data->upath : "");
|
||||||
if (rc == -1)
|
if (rc == -1) {
|
||||||
|
env[2] = NULL;
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
rc = asprintf(&env[3], "VDEV_ENC_SYSFS_PATH=%s",
|
rc = asprintf(&env[3], "VDEV_ENC_SYSFS_PATH=%s",
|
||||||
data->vdev_enc_sysfs_path ?
|
data->vdev_enc_sysfs_path ?
|
||||||
data->vdev_enc_sysfs_path : "");
|
data->vdev_enc_sysfs_path : "");
|
||||||
if (rc == -1)
|
if (rc == -1) {
|
||||||
|
env[3] = NULL;
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
/* Run the command */
|
/* Run the command */
|
||||||
rc = libzfs_run_process_get_stdout_nopath(cmd, argv, env, &lines,
|
rc = libzfs_run_process_get_stdout_nopath(cmd, argv, env, &lines,
|
||||||
@ -525,8 +531,7 @@ out:
|
|||||||
|
|
||||||
/* Start with i = 1 since env[0] was statically allocated */
|
/* Start with i = 1 since env[0] was statically allocated */
|
||||||
for (i = 1; i < ARRAY_SIZE(env); i++)
|
for (i = 1; i < ARRAY_SIZE(env); i++)
|
||||||
if (env[i] != NULL)
|
free(env[i]);
|
||||||
free(env[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user