diff options
author | Don Brady <[email protected]> | 2018-08-03 15:50:51 -0600 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2018-08-03 14:50:51 -0700 |
commit | fc1ecd16d735eb35939a5cae9488b00b1539e383 (patch) | |
tree | cf75f806ad932af3b6c0e7453b6943eabe1486c0 /module/zfs | |
parent | 6da0998f592a322ca045dec1c9db61333c9936dc (diff) |
zfs_ioc_unload_key can drop extra spa ref
Reviewed by: Thomas Caputi <[email protected]>
Reviewed by: Matt Ahrens <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Don Brady <[email protected]>
Closes #7759
Diffstat (limited to 'module/zfs')
-rw-r--r-- | module/zfs/dsl_crypt.c | 16 | ||||
-rw-r--r-- | module/zfs/dsl_dir.c | 3 |
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); |