summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorMatthew Ahrens <[email protected]>2020-12-24 21:07:24 -0800
committerBrian Behlendorf <[email protected]>2020-12-28 10:05:55 -0800
commit808e6812386b1c93a90be685a3f71342596df203 (patch)
tree7edccc6892ce40efc553ba7af3d2d156eaa43993 /cmd
parentf014700a3768fcfcf0be61e1b9fc96e847272d98 (diff)
Memory leak in zdb:import_checkpointed_state()
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.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c
index 2541679ad..e45bff269 100644
--- a/cmd/zdb/zdb.c
+++ b/cmd/zdb/zdb.c
@@ -6762,6 +6762,7 @@ import_checkpointed_state(char *target, nvlist_t *cfg, char **new_path)
{
int error = 0;
char *poolname, *bogus_name = NULL;
+ boolean_t freecfg = B_FALSE;
/* If the target is not a pool, the extract the pool name */
char *path_start = strchr(target, '/');
@@ -6780,6 +6781,7 @@ import_checkpointed_state(char *target, nvlist_t *cfg, char **new_path)
"spa_get_stats() failed with error %d\n",
poolname, error);
}
+ freecfg = B_TRUE;
}
if (asprintf(&bogus_name, "%s%s", poolname, BOGUS_SUFFIX) == -1)
@@ -6789,6 +6791,8 @@ import_checkpointed_state(char *target, nvlist_t *cfg, char **new_path)
error = spa_import(bogus_name, cfg, NULL,
ZFS_IMPORT_MISSING_LOG | ZFS_IMPORT_CHECKPOINT |
ZFS_IMPORT_SKIP_MMP);
+ if (freecfg)
+ nvlist_free(cfg);
if (error != 0) {
fatal("Tried to import pool \"%s\" but spa_import() failed "
"with error %d\n", bogus_name, error);
@@ -7017,7 +7021,6 @@ verify_checkpoint_blocks(spa_t *spa)
spa_t *checkpoint_spa;
char *checkpoint_pool;
- nvlist_t *config = NULL;
int error = 0;
/*
@@ -7025,7 +7028,7 @@ verify_checkpoint_blocks(spa_t *spa)
* name) so we can do verification on it against the current state
* of the pool.
*/
- checkpoint_pool = import_checkpointed_state(spa->spa_name, config,
+ checkpoint_pool = import_checkpointed_state(spa->spa_name, NULL,
NULL);
ASSERT(strcmp(spa->spa_name, checkpoint_pool) != 0);