HomeFreeBSD

Avoid calling rw_destroy() on uninitialized rwlock

Description

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

Details

Provenance
Jorgen Lundman <lundman@lundman.net>Authored on Oct 6 2022, 12:07 AM
Tony Hutter <hutter2@llnl.gov>Committed on Feb 21 2024, 9:35 PM
Parents
rG00a3821020c3: Fix GCC 12 compilation errors
Branches
Unknown
Tags
Unknown