diff options
author | Matthew Ahrens <[email protected]> | 2020-12-23 09:52:24 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2020-12-28 10:05:31 -0800 |
commit | b6722b871b141b29adb5ae46455b7d96620fa993 (patch) | |
tree | d367be7860998a93ba96ea3a56c63b7b00c909a6 /cmd | |
parent | 40ab927ae817b44fcb7fa043a8073c5f049f9257 (diff) |
nvlist leaked in zpool_find_config()
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 <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Matthew Ahrens <[email protected]>
Closes #11396
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/zdb/zdb.c | 10 | ||||
-rw-r--r-- | cmd/zhack/zhack.c | 1 | ||||
-rw-r--r-- | cmd/ztest/ztest.c | 1 |
3 files changed, 12 insertions, 0 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index ff0c61d64..2541679ad 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -8435,6 +8435,11 @@ main(int argc, char **argv) } } + 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 @@ -8453,6 +8458,11 @@ main(int argc, char **argv) target = checkpoint_target; } + if (cfg != NULL) { + nvlist_free(cfg); + cfg = NULL; + } + if (target_pool != target) free(target_pool); diff --git a/cmd/zhack/zhack.c b/cmd/zhack/zhack.c index 4d958fe43..08263120c 100644 --- a/cmd/zhack/zhack.c +++ b/cmd/zhack/zhack.c @@ -150,6 +150,7 @@ zhack_import(char *target, boolean_t readonly) 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; diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c index 4f6c931a3..21a7d4ad5 100644 --- a/cmd/ztest/ztest.c +++ b/cmd/ztest/ztest.c @@ -7153,6 +7153,7 @@ ztest_import_impl(ztest_shared_t *zs) 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); } /* |