In `zpool_find_config()`, the `pools` nvlist is leaked. Part of it (a
sub-nvlist) is returned in `*configp`, but the callers also leak that.
Additionally, in `zdb.c:main()`, the `searchdirs` is leaked.
The leaks were detected by ASAN (`configure --enable-asan`).
This commit resolves the leaks.
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #11396
}
}
+ if (searchdirs != NULL) {
+ umem_free(searchdirs, nsearch * sizeof (char *));
+ searchdirs = NULL;
+ }
+
/*
* import_checkpointed_state makes the assumption that the
* target pool that we pass it is already part of the spa
target = checkpoint_target;
}
+ if (cfg != NULL) {
+ nvlist_free(cfg);
+ cfg = NULL;
+ }
+
if (target_pool != target)
free(target_pool);
zfeature_checks_disable = B_TRUE;
error = spa_import(target, config, props,
(readonly ? ZFS_IMPORT_SKIP_MMP : ZFS_IMPORT_NORMAL));
+ fnvlist_free(config);
zfeature_checks_disable = B_FALSE;
if (error == EEXIST)
error = 0;
VERIFY0(zpool_find_config(NULL, ztest_opts.zo_pool, &cfg, &args,
&libzpool_config_ops));
VERIFY0(spa_import(ztest_opts.zo_pool, cfg, NULL, flags));
+ fnvlist_free(cfg);
}
/*
nvlist_t *pools;
nvlist_t *match = NULL;
nvlist_t *config = NULL;
- char *name = NULL, *sepp = NULL;
+ char *sepp = NULL;
char sep = '\0';
int count = 0;
char *targetdup = strdup(target);
/* multiple matches found */
continue;
} else {
- match = config;
- name = nvpair_name(elem);
+ match = fnvlist_dup(config);
}
}
}
+ fnvlist_free(pools);
}
if (count == 0) {
if (count > 1) {
free(targetdup);
+ fnvlist_free(match);
return (EINVAL);
}