diff options
author | Jorgen Lundman <[email protected]> | 2019-04-11 07:39:40 +0900 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-04-10 15:39:40 -0700 |
commit | 48ed0f9da0389f3ad44e494b00055c8563f961a1 (patch) | |
tree | 311279b2c75da26536051eed845cc52f76729c67 | |
parent | 8cb34421e0bf1fea316d16014483d61381a41f57 (diff) |
Always call rw_init in zio_crypt_key_unwrap
The error path in zio_crypt_key_unwrap would call zio_crypt_key_destroy which
calls rw_destroy(&key->zk_salt_lock); which has not yet been initialized.
We move the rw_init() call to the start of zio_crypt_key_unwrap instead.
Reviewed-by: Tom Caputi <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Jorgen Lundman <[email protected]>
Closes #8604
Closes #8605
-rw-r--r-- | module/zfs/zio_crypt.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/module/zfs/zio_crypt.c b/module/zfs/zio_crypt.c index 2533aee13..eb781b64f 100644 --- a/module/zfs/zio_crypt.c +++ b/module/zfs/zio_crypt.c @@ -559,6 +559,8 @@ zio_crypt_key_unwrap(crypto_key_t *cwkey, uint64_t crypt, uint64_t version, ASSERT3U(crypt, <, ZIO_CRYPT_FUNCTIONS); ASSERT3U(cwkey->ck_format, ==, CRYPTO_KEY_RAW); + rw_init(&key->zk_salt_lock, NULL, RW_DEFAULT, NULL); + keydata_len = zio_crypt_table[crypt].ci_keylen; /* initialize uio_ts */ @@ -640,7 +642,6 @@ zio_crypt_key_unwrap(crypto_key_t *cwkey, uint64_t crypt, uint64_t version, key->zk_version = version; key->zk_guid = guid; key->zk_salt_count = 0; - rw_init(&key->zk_salt_lock, NULL, RW_DEFAULT, NULL); return (0); |