]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Always call rw_init in zio_crypt_key_unwrap
authorJorgen Lundman <lundman@lundman.net>
Wed, 10 Apr 2019 22:39:40 +0000 (07:39 +0900)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 10 Apr 2019 22:39:40 +0000 (15:39 -0700)
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 <tcaputi@datto.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Jorgen Lundman <lundman@lundman.net>
Closes #8604
Closes #8605

module/zfs/zio_crypt.c

index 2533aee139f6dbe1fb5e2680385cd76e4e69314d..eb781b64fa1d442035f6e43dee73bbb2dc1b7025 100644 (file)
@@ -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);