]> git.proxmox.com Git - mirror_zfs.git/commit
Avoid calling rw_destroy() on uninitialized rwlock
authorJorgen Lundman <lundman@lundman.net>
Thu, 6 Oct 2022 00:07:50 +0000 (09:07 +0900)
committerGitHub <noreply@github.com>
Thu, 6 Oct 2022 00:07:50 +0000 (17:07 -0700)
commit4b629d04a5b8d26122ce6b0bf2eb9d1d78b382b0
tree367c112c7fcf801bfbca28b8dfe1e271c7387e03
parent062d3d056bf2b721f3db68f5c368b1c722ac8585
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
module/os/linux/zfs/zio_crypt.c