diff --git a/crypto/evp/signature.c b/crypto/evp/signature.c index 30a5c9a0d8d0e..fc023362f355e 100644 --- a/crypto/evp/signature.c +++ b/crypto/evp/signature.c @@ -407,18 +407,17 @@ static int evp_pkey_signature_init(EVP_PKEY_CTX *ctx, int operation, evp_pkey_ctx_free_old_ops(ctx); ctx->operation = operation; - ERR_set_mark(); - - if (evp_pkey_ctx_is_legacy(ctx)) - goto legacy; if (ctx->pkey == NULL) { - ERR_clear_last_mark(); ERR_raise(ERR_LIB_EVP, EVP_R_NO_KEY_SET); goto err; } keynid = ctx->pkey->type; + ERR_set_mark(); + if (evp_pkey_ctx_is_legacy(ctx)) + goto legacy; + /* * Try to derive the supported signature from |ctx->keymgmt|. */