[CRIU] [PATCH] uffd: don't close the same descriptor twice

Andrey Vagin avagin at openvz.org
Fri May 13 14:42:35 PDT 2016


From: Andrew Vagin <avagin at virtuozzo.com>

>>>     CID 161322:  API usage errors  (USE_AFTER_FREE)
>>>     Calling "close(int)" closes handle "client" which has already been closed.

Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 criu/uffd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/criu/uffd.c b/criu/uffd.c
index fb0cab1..97779fd 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -288,7 +288,7 @@ static struct lazy_pages_info *ud_open(int listen, struct sockaddr_un *saddr)
 		goto out;
 	}
 	pr_debug("lpi->uffd %d\n", lpi->uffd);
-	close(client);
+	close_safe(&client);
 
 	pr_debug("uffd is 0x%d\n", lpi->uffd);
 	uffd_flags = fcntl(lpi->uffd, F_GETFD, NULL);
@@ -307,7 +307,7 @@ static struct lazy_pages_info *ud_open(int listen, struct sockaddr_un *saddr)
 
 out:
 	free(lpi);
-	close(client);
+	close_safe(&client);
 	return NULL;
 }
 
-- 
2.7.4



More information about the CRIU mailing list