From b295a4dca17f00d412043b74393b86a16655fac0 Mon Sep 17 00:00:00 2001
From: Tristan Bauer <67098820+trisbauer@users.noreply.github.com>
Date: Thu, 18 Jun 2020 11:45:24 +0200
Subject: [PATCH 028/147] Fix wrong return value check of mmap function

The mmap function never returns NULL. If an error occurs, the function returns MAP_FAILED.

CLA: trivial

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12187)

(cherry picked from commit 1d78129dd205e3e85083a91c33540a70c51b0a23)
---
 crypto/mem_sec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/mem_sec.c b/crypto/mem_sec.c
index 9e0f670..8bcb050 100644
--- a/crypto/mem_sec.c
+++ b/crypto/mem_sec.c
@@ -502,7 +502,7 @@ static void sh_done(void)
     OPENSSL_free(sh.freelist);
     OPENSSL_free(sh.bittable);
     OPENSSL_free(sh.bitmalloc);
-    if (sh.map_result != NULL && sh.map_size)
+    if (sh.map_result != MAP_FAILED && sh.map_size)
         munmap(sh.map_result, sh.map_size);
     memset(&sh, 0, sizeof(sh));
 }
-- 
1.8.3.1

