From 48ed0f9da0389f3ad44e494b00055c8563f961a1 Mon Sep 17 00:00:00 2001 From: Jorgen Lundman Date: Thu, 11 Apr 2019 07:39:40 +0900 Subject: 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 Reviewed-by: Brian Behlendorf Signed-off-by: Jorgen Lundman Closes #8604 Closes #8605 --- module/zfs/zio_crypt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'module/zfs') 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); -- cgit v1.2.3