engines/e_devcrypto: fixes logic in close_devcrypto
authorEneas U de Queiroz <cote2004-github@yahoo.com>
Fri, 15 Feb 2019 17:51:59 +0000 (15:51 -0200)
committerRichard Levitte <levitte@openssl.org>
Fri, 22 Feb 2019 08:42:56 +0000 (09:42 +0100)
Call close(cfd) before setting cfd = -1.

Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8213)

engines/e_devcrypto.c

index 359a486..c578629 100644 (file)
@@ -1183,10 +1183,13 @@ static int open_devcrypto(void)
 
 static int close_devcrypto(void)
 {
+    int ret;
+
     if (cfd < 0)
         return 1;
+    ret = close(cfd);
     cfd = -1;
-    if (close(cfd) == 0) {
+    if (ret != 0) {
         fprintf(stderr, "Error closing /dev/crypto: %s\n", strerror(errno));
         return 0;
     }