Skip to content

Commit 808e681

Browse files
ahrensbehlendorf
authored andcommitted
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
1 parent f014700 commit 808e681

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cmd/zdb/zdb.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6762,6 +6762,7 @@ import_checkpointed_state(char *target, nvlist_t *cfg, char **new_path)
67626762
{
67636763
int error = 0;
67646764
char *poolname, *bogus_name = NULL;
6765+
boolean_t freecfg = B_FALSE;
67656766

67666767
/* If the target is not a pool, the extract the pool name */
67676768
char *path_start = strchr(target, '/');
@@ -6780,6 +6781,7 @@ import_checkpointed_state(char *target, nvlist_t *cfg, char **new_path)
67806781
"spa_get_stats() failed with error %d\n",
67816782
poolname, error);
67826783
}
6784+
freecfg = B_TRUE;
67836785
}
67846786

67856787
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)
67896791
error = spa_import(bogus_name, cfg, NULL,
67906792
ZFS_IMPORT_MISSING_LOG | ZFS_IMPORT_CHECKPOINT |
67916793
ZFS_IMPORT_SKIP_MMP);
6794+
if (freecfg)
6795+
nvlist_free(cfg);
67926796
if (error != 0) {
67936797
fatal("Tried to import pool \"%s\" but spa_import() failed "
67946798
"with error %d\n", bogus_name, error);
@@ -7017,15 +7021,14 @@ verify_checkpoint_blocks(spa_t *spa)
70177021

70187022
spa_t *checkpoint_spa;
70197023
char *checkpoint_pool;
7020-
nvlist_t *config = NULL;
70217024
int error = 0;
70227025

70237026
/*
70247027
* We import the checkpointed state of the pool (under a different
70257028
* name) so we can do verification on it against the current state
70267029
* of the pool.
70277030
*/
7028-
checkpoint_pool = import_checkpointed_state(spa->spa_name, config,
7031+
checkpoint_pool = import_checkpointed_state(spa->spa_name, NULL,
70297032
NULL);
70307033
ASSERT(strcmp(spa->spa_name, checkpoint_pool) != 0);
70317034

0 commit comments

Comments
 (0)