diff options
author | sara hartse <sara.hartse@delphix.com> | 2017-09-07 13:10:53 -0700 |
---|---|---|
committer | Prakash Surya <prakash.surya@delphix.com> | 2018-06-01 09:22:51 -0700 |
commit | ddfe901b12348d31c500fb57f9174e88860a4061 (patch) | |
tree | 52fd50064278088b3f4592552603e9fae1c1eb70 | |
parent | 69d4acec15909325d6df21fec172510a50f77a8a (diff) | |
download | illumos-joyent-ddfe901b12348d31c500fb57f9174e88860a4061.tar.gz |
9457 libzfs_import.c:add_config() has a memory leak
Reviewed by: Matt Ahrens <matt@delphix.com>
Reviewed by: Serapheim Dimitropoulos <serapheim.dimitro@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
-rw-r--r-- | usr/src/lib/libzfs/common/libzfs_import.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/usr/src/lib/libzfs/common/libzfs_import.c b/usr/src/lib/libzfs/common/libzfs_import.c index d28e852ef6..5bd900ad00 100644 --- a/usr/src/lib/libzfs/common/libzfs_import.c +++ b/usr/src/lib/libzfs/common/libzfs_import.c @@ -33,7 +33,7 @@ * ZFS label of each device. If we successfully read the label, then we * organize the configuration information in the following hierarchy: * - * pool guid -> toplevel vdev guid -> label txg + * pool guid -> toplevel vdev guid -> label txg * * Duplicate entries matching this same tuple will be discarded. Once we have * examined every device, we pick the best label txg config for each toplevel @@ -217,7 +217,6 @@ add_config(libzfs_handle_t *hdl, pool_list_t *pl, const char *path, ne->ne_next = pl->names; pl->names = ne; - nvlist_free(config); return (0); } @@ -237,7 +236,6 @@ add_config(libzfs_handle_t *hdl, pool_list_t *pl, const char *path, &top_guid) != 0 || nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_TXG, &txg) != 0 || txg == 0) { - nvlist_free(config); return (0); } @@ -252,7 +250,6 @@ add_config(libzfs_handle_t *hdl, pool_list_t *pl, const char *path, if (pe == NULL) { if ((pe = zfs_alloc(hdl, sizeof (pool_entry_t))) == NULL) { - nvlist_free(config); return (-1); } pe->pe_guid = pool_guid; @@ -271,7 +268,6 @@ add_config(libzfs_handle_t *hdl, pool_list_t *pl, const char *path, if (ve == NULL) { if ((ve = zfs_alloc(hdl, sizeof (vdev_entry_t))) == NULL) { - nvlist_free(config); return (-1); } ve->ve_guid = top_guid; @@ -291,15 +287,12 @@ add_config(libzfs_handle_t *hdl, pool_list_t *pl, const char *path, if (ce == NULL) { if ((ce = zfs_alloc(hdl, sizeof (config_entry_t))) == NULL) { - nvlist_free(config); return (-1); } ce->ce_txg = txg; - ce->ce_config = config; + ce->ce_config = fnvlist_dup(config); ce->ce_next = ve->ve_configs; ve->ve_configs = ce; - } else { - nvlist_free(config); } /* @@ -1235,9 +1228,7 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg) &this_guid) == 0 && iarg->guid == this_guid; } - if (!matched) { - nvlist_free(config); - } else { + if (matched) { /* * use the non-raw path for the config */ @@ -1247,6 +1238,7 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg) config) != 0) config_failed = B_TRUE; } + nvlist_free(config); } free(slice->rn_name); free(slice); |