aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/zfs/dsl_crypt.c16
-rw-r--r--module/zfs/dsl_dir.c3
2 files changed, 14 insertions, 5 deletions
diff --git a/module/zfs/dsl_crypt.c b/module/zfs/dsl_crypt.c
index e2067448c..9bdfc8d91 100644
--- a/module/zfs/dsl_crypt.c
+++ b/module/zfs/dsl_crypt.c
@@ -469,8 +469,10 @@ dsl_crypto_can_set_keylocation(const char *dsname, const char *keylocation)
goto out;
ret = dsl_dir_hold(dp, dsname, FTAG, &dd, NULL);
- if (ret != 0)
+ if (ret != 0) {
+ dd = NULL;
goto out;
+ }
/* if dd is not encrypted, the value may only be "none" */
if (dd->dd_crypto_obj == 0) {
@@ -778,8 +780,10 @@ spa_keystore_load_wkey(const char *dsname, dsl_crypto_params_t *dcp,
/* hold the dsl dir */
ret = dsl_dir_hold(dp, dsname, FTAG, &dd, NULL);
- if (ret != 0)
+ if (ret != 0) {
+ dd = NULL;
goto error;
+ }
/* initialize the wkey's ddobj */
wkey->wk_ddobj = dd->dd_object;
@@ -904,8 +908,10 @@ spa_keystore_unload_wkey(const char *dsname)
}
ret = dsl_dir_hold(dp, dsname, FTAG, &dd, NULL);
- if (ret != 0)
+ if (ret != 0) {
+ dd = NULL;
goto error;
+ }
/* unload the wkey */
ret = spa_keystore_unload_wkey_impl(dp->dp_spa, dd->dd_object);
@@ -1205,8 +1211,10 @@ spa_keystore_change_key_check(void *arg, dmu_tx_t *tx)
/* hold the dd */
ret = dsl_dir_hold(dp, skcka->skcka_dsname, FTAG, &dd, NULL);
- if (ret != 0)
+ if (ret != 0) {
+ dd = NULL;
goto error;
+ }
/* verify that the dataset is encrypted */
if (dd->dd_crypto_obj == 0) {
diff --git a/module/zfs/dsl_dir.c b/module/zfs/dsl_dir.c
index 9a43691e5..5b6ce0420 100644
--- a/module/zfs/dsl_dir.c
+++ b/module/zfs/dsl_dir.c
@@ -501,7 +501,8 @@ dsl_dir_hold(dsl_pool_t *dp, const char *name, void *tag,
}
if (tailp != NULL)
*tailp = next;
- *ddp = dd;
+ if (err == 0)
+ *ddp = dd;
error:
kmem_free(buf, ZFS_MAX_DATASET_NAME_LEN);
return (err);