From f014700a3768fcfcf0be61e1b9fc96e847272d98 Mon Sep 17 00:00:00 2001 From: Matthew Ahrens Date: Thu, 24 Dec 2020 20:58:17 -0800 Subject: [PATCH] Memory leak in ztest_dmu_objset_own() Reviewed-by: Igor Kozhukhov Reviewed-by: Ryan Moeller Reviewed-by: Brian Behlendorf Signed-off-by: Matthew Ahrens Closes #11396 --- cmd/ztest/ztest.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c index b59f7dfc8b..f66772fa72 100644 --- a/cmd/ztest/ztest.c +++ b/cmd/ztest/ztest.c @@ -1441,7 +1441,11 @@ ztest_dmu_objset_own(const char *name, dmu_objset_type_t type, VERIFY0(dsl_crypto_params_create_nvlist(DCP_CMD_NONE, NULL, crypto_args, &dcp)); err = spa_keystore_load_wkey(ddname, dcp, B_FALSE); - dsl_crypto_params_free(dcp, B_FALSE); + /* + * Note: if there was an error loading, the wkey was not + * consumed, and needs to be freed. + */ + dsl_crypto_params_free(dcp, (err != 0)); fnvlist_free(crypto_args); if (err == EINVAL) {