aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libzutil
diff options
context:
space:
mode:
authorMatthew Ahrens <[email protected]>2020-12-23 09:52:24 -0800
committerBrian Behlendorf <[email protected]>2021-01-05 10:31:47 -0800
commita296875da080a93aa1aef7cea0aace4f6e867cab (patch)
treee1492bc878cb5409fdc828126ee47dab485a8168 /lib/libzutil
parent921ec61b7712e60dd9ec4fc1161dc6d45d62c0e7 (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 'lib/libzutil')
-rw-r--r--lib/libzutil/zutil_import.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libzutil/zutil_import.c b/lib/libzutil/zutil_import.c
index b8cdc118b..3a1827294 100644
--- a/lib/libzutil/zutil_import.c
+++ b/lib/libzutil/zutil_import.c
@@ -1539,7 +1539,7 @@ zpool_find_config(void *hdl, const char *target, nvlist_t **configp,
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);
@@ -1563,11 +1563,11 @@ zpool_find_config(void *hdl, const char *target, nvlist_t **configp,
/* multiple matches found */
continue;
} else {
- match = config;
- name = nvpair_name(elem);
+ match = fnvlist_dup(config);
}
}
}
+ fnvlist_free(pools);
}
if (count == 0) {
@@ -1577,6 +1577,7 @@ zpool_find_config(void *hdl, const char *target, nvlist_t **configp,
if (count > 1) {
free(targetdup);
+ fnvlist_free(match);
return (EINVAL);
}