From c2550a136ed578c20dc412ae427f3c9ca29e5e0c Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Sat, 4 Mar 2023 23:48:06 -0500 Subject: [PATCH] Linux: Silence static analyzer warning in crypto_create_ctx_template() A CodeChecker report from Clang's CTU analysis indicated that we were assigning uninitialized values in crypto_create_ctx_template() when we call it from zio_crypt_key_init(). This occurs because the ->cm_param and ->cm_param_len fields are uninitialized. Thankfully, the uninitialized values are only used in the skein via KCF_PROV_CREATE_CTX_TEMPLATE() -> skein_create_ctx_template() -> skein_mac_ctx_build() -> skein_get_digest_bitlen(), but that should not be called from here. We fix this to avoid a possible trap should this code change in the future. The FreeBSD version of zio_crypt_key_init() is unaffected. Reviewed-by: Brian Behlendorf Signed-off-by: Richard Yao Closes #14575 --- module/os/linux/zfs/zio_crypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/os/linux/zfs/zio_crypt.c b/module/os/linux/zfs/zio_crypt.c index a9043ae4d..55554d09e 100644 --- a/module/os/linux/zfs/zio_crypt.c +++ b/module/os/linux/zfs/zio_crypt.c @@ -223,7 +223,7 @@ int zio_crypt_key_init(uint64_t crypt, zio_crypt_key_t *key) { int ret; - crypto_mechanism_t mech; + crypto_mechanism_t mech = {0}; uint_t keydata_len; ASSERT(key != NULL);