Found by Linux Verification Center (linuxtesting.org) with SVACE.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/29458)
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,
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 */
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);
operation cache slot. If I<keymgmt> is NULL, or if there is no slot
with a match for I<keymgmt>, 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
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);