From: JohnnySavages Date: Fri, 19 Dec 2025 06:05:07 +0000 (-0500) Subject: Change evp_keymgmt_util_clear_operation_cache return type to void X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab1b8837c64dac7ddde0f00544c17e722df698a3;p=thirdparty%2Fopenssl.git Change evp_keymgmt_util_clear_operation_cache return type to void Found by Linux Verification Center (linuxtesting.org) with SVACE. Reviewed-by: Tomas Mraz Reviewed-by: Frederik Wedel-Heinen Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/29458) --- diff --git a/crypto/evp/keymgmt_lib.c b/crypto/evp/keymgmt_lib.c index 04ac443aada..c4b08c0ed68 100644 --- a/crypto/evp/keymgmt_lib.c +++ b/crypto/evp/keymgmt_lib.c @@ -219,14 +219,13 @@ static void op_cache_free(OP_CACHE_ELEM *e) OPENSSL_free(e); } -int evp_keymgmt_util_clear_operation_cache(EVP_PKEY *pk) +void evp_keymgmt_util_clear_operation_cache(EVP_PKEY *pk) { - if (pk != NULL) { - sk_OP_CACHE_ELEM_pop_free(pk->operation_cache, op_cache_free); - pk->operation_cache = NULL; - } + if (pk == NULL) + return; - return 1; + sk_OP_CACHE_ELEM_pop_free(pk->operation_cache, op_cache_free); + pk->operation_cache = NULL; } OP_CACHE_ELEM *evp_keymgmt_util_find_operation_cache(EVP_PKEY *pk, diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index ab5ad82d08b..b784e243df0 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -1921,14 +1921,10 @@ void *evp_pkey_export_to_provider(EVP_PKEY *pk, OSSL_LIB_CTX *libctx, if (!CRYPTO_THREAD_write_lock(pk->lock)) goto end; - if (pk->ameth->dirty_cnt(pk) != pk->dirty_cnt_copy - && !evp_keymgmt_util_clear_operation_cache(pk)) { - CRYPTO_THREAD_unlock(pk->lock); - evp_keymgmt_freedata(tmp_keymgmt, keydata); - keydata = NULL; - EVP_KEYMGMT_free(tmp_keymgmt); - goto end; - } + + if (pk->ameth->dirty_cnt(pk) != pk->dirty_cnt_copy) + evp_keymgmt_util_clear_operation_cache(pk); + EVP_KEYMGMT_free(tmp_keymgmt); /* refcnt-- */ /* Check to make sure some other thread didn't get there first */ diff --git a/doc/internal/man3/evp_keymgmt_util_export_to_provider.pod b/doc/internal/man3/evp_keymgmt_util_export_to_provider.pod index 5823cd200f5..8f5397d6c2a 100644 --- a/doc/internal/man3/evp_keymgmt_util_export_to_provider.pod +++ b/doc/internal/man3/evp_keymgmt_util_export_to_provider.pod @@ -25,7 +25,7 @@ OP_CACHE_ELEM OP_CACHE_ELEM *evp_keymgmt_util_find_operation_cache(EVP_PKEY *pk, EVP_KEYMGMT *keymgmt, int selection); - int evp_keymgmt_util_clear_operation_cache(EVP_PKEY *pk); + void evp_keymgmt_util_clear_operation_cache(EVP_PKEY *pk); int evp_keymgmt_util_cache_keydata(EVP_PKEY *pk, EVP_KEYMGMT *keymgmt, void *keydata, int selection); void evp_keymgmt_util_cache_keyinfo(EVP_PKEY *pk); @@ -81,8 +81,7 @@ evp_keymgmt_util_find_operation_cache() returns a pointer to the operation cache slot. If I is NULL, or if there is no slot with a match for I, NULL is returned. -evp_keymgmt_util_cache_keydata() and evp_keymgmt_util_clear_operation_cache() -return 1 on success or 0 otherwise. +evp_keymgmt_util_cache_keydata() return 1 on success or 0 otherwise. =head1 NOTES diff --git a/include/crypto/evp.h b/include/crypto/evp.h index 85e13e520b8..021fac3df11 100644 --- a/include/crypto/evp.h +++ b/include/crypto/evp.h @@ -535,7 +535,7 @@ void *evp_keymgmt_util_export_to_provider(EVP_PKEY *pk, EVP_KEYMGMT *keymgmt, OP_CACHE_ELEM *evp_keymgmt_util_find_operation_cache(EVP_PKEY *pk, EVP_KEYMGMT *keymgmt, int selection); -int evp_keymgmt_util_clear_operation_cache(EVP_PKEY *pk); +void evp_keymgmt_util_clear_operation_cache(EVP_PKEY *pk); int evp_keymgmt_util_cache_keydata(EVP_PKEY *pk, EVP_KEYMGMT *keymgmt, void *keydata, int selection); void evp_keymgmt_util_cache_keyinfo(EVP_PKEY *pk);