mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-17 01:51:00 +03:00
Avoid calling rw_destroy() on uninitialized rwlock
First the function `memset(&key, 0, ...)` but any call to "goto error;" would call zio_crypt_key_destroy(key) which calls `rw_destroy()`. The `rw_init()` is moved up to be right after the memset. This way the rwlock can be released. The ctx does allocate memory, but that is handled by the memset to 0 and icp skips NULL ptrs. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu> Signed-off-by: Jorgen Lundman <lundman@lundman.net> Closes #13976
This commit is contained in:
parent
00a3821020
commit
3ad8826585
@ -249,6 +249,7 @@ zio_crypt_key_init(uint64_t crypt, zio_crypt_key_t *key)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
memset(key, 0, sizeof (zio_crypt_key_t));
|
||||
rw_init(&key->zk_salt_lock, NULL, RW_DEFAULT, NULL);
|
||||
|
||||
/* fill keydata buffers and salt with random data */
|
||||
ret = random_get_bytes((uint8_t *)&key->zk_guid, sizeof (uint64_t));
|
||||
@ -302,7 +303,6 @@ zio_crypt_key_init(uint64_t crypt, zio_crypt_key_t *key)
|
||||
key->zk_crypt = crypt;
|
||||
key->zk_version = ZIO_CRYPT_KEY_CURRENT_VERSION;
|
||||
key->zk_salt_count = 0;
|
||||
rw_init(&key->zk_salt_lock, NULL, RW_DEFAULT, NULL);
|
||||
|
||||
return (0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user