engines/e_devcrypto: fixes logic in close_devcrypto
[openssl.git] / engines / e_devcrypto.c
index 359a48631a22ebefdeb55d4f099c5dedab0830ef..c57862969ece4d2ad93ba35f34240fca0bbfd48a 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;
     }