diff options
Diffstat (limited to 'cmd/zpool')
-rw-r--r-- | cmd/zpool/zpool_iter.c | 2 | ||||
-rw-r--r-- | cmd/zpool/zpool_vdev.c | 13 |
2 files changed, 13 insertions, 2 deletions
diff --git a/cmd/zpool/zpool_iter.c b/cmd/zpool/zpool_iter.c index a18ccf29d..1b64a5a5c 100644 --- a/cmd/zpool/zpool_iter.c +++ b/cmd/zpool/zpool_iter.c @@ -308,7 +308,7 @@ for_each_vdev_cb(zpool_handle_t *zhp, nvlist_t *nv, pool_vdev_iter_f func, int for_each_vdev(zpool_handle_t *zhp, pool_vdev_iter_f func, void *data) { - nvlist_t *config, *nvroot; + nvlist_t *config, *nvroot = NULL; if ((config = zpool_get_config(zhp, NULL)) != NULL) { verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, diff --git a/cmd/zpool/zpool_vdev.c b/cmd/zpool/zpool_vdev.c index 587aa7fd4..3f419079c 100644 --- a/cmd/zpool/zpool_vdev.c +++ b/cmd/zpool/zpool_vdev.c @@ -1522,8 +1522,13 @@ construct_spec(nvlist_t *props, int argc, char **argv) if (child == NULL) zpool_no_memory(); if ((nv = make_leaf_vdev(props, argv[c], - B_FALSE)) == NULL) + B_FALSE)) == NULL) { + for (c = 0; c < children - 1; c++) + nvlist_free(child[c]); + free(child); return (NULL); + } + child[children - 1] = nv; } @@ -1531,6 +1536,9 @@ construct_spec(nvlist_t *props, int argc, char **argv) (void) fprintf(stderr, gettext("invalid vdev " "specification: %s requires at least %d " "devices\n"), argv[0], mindev); + for (c = 0; c < children; c++) + nvlist_free(child[c]); + free(child); return (NULL); } @@ -1538,6 +1546,9 @@ construct_spec(nvlist_t *props, int argc, char **argv) (void) fprintf(stderr, gettext("invalid vdev " "specification: %s supports no more than " "%d devices\n"), argv[0], maxdev); + for (c = 0; c < children; c++) + nvlist_free(child[c]); + free(child); return (NULL); } |