1 From 5378c582c8d3f1130b17abb2950bfd09cde099c6 Mon Sep 17 00:00:00 2001
2 From: Eneas U de Queiroz <cote2004-github@yahoo.com>
3 Date: Mon, 5 Nov 2018 15:59:44 -0200
4 Subject: [PATCH 4/7] eng_devcrypto: close session on cleanup, not final
6 Close the session in digest_cleanup instead of digest_final. A failure
7 in closing the session does not mean a previous successful digest final
10 Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
12 Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
13 Reviewed-by: Richard Levitte <levitte@openssl.org>
14 (Merged from https://github.com/openssl/openssl/pull/7585)
16 (cherry picked from commit a67203a19d379a8cc8b369587c60c46eb4e19014)
18 --- a/crypto/engine/eng_devcrypto.c
19 +++ b/crypto/engine/eng_devcrypto.c
20 @@ -461,10 +461,6 @@ static int digest_final(EVP_MD_CTX *ctx,
21 SYSerr(SYS_F_IOCTL, errno);
24 - if (ioctl(cfd, CIOCFSESSION, &digest_ctx->sess.ses) < 0) {
25 - SYSerr(SYS_F_IOCTL, errno);
31 @@ -496,6 +492,15 @@ static int digest_copy(EVP_MD_CTX *to, c
33 static int digest_cleanup(EVP_MD_CTX *ctx)
35 + struct digest_ctx *digest_ctx =
36 + (struct digest_ctx *)EVP_MD_CTX_md_data(ctx);
38 + if (digest_ctx == NULL)
40 + if (ioctl(cfd, CIOCFSESSION, &digest_ctx->sess.ses) < 0) {
41 + SYSerr(SYS_F_IOCTL, errno);