[CRIU] [PATCH] files: don't leak a socket in error cases

Andrei Vagin avagin at openvz.org
Thu Dec 8 13:50:34 PST 2016


From: Andrei Vagin <avagin at virtuozzo.com>

CID 173074 (#1 of 1): Resource leak (RESOURCE_LEAK)
9. leaked_handle: Handle variable sock going out of scope leaks the handle.

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 criu/files.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/criu/files.c b/criu/files.c
index e691558..b371433 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -1683,6 +1683,7 @@ int open_transport_socket(void)
 	transport_name_gen(&saddr, &slen, pid, -1);
 	if (bind(sock, (struct sockaddr *)&saddr, slen) < 0) {
 		pr_perror("Can't bind transport socket %s", saddr.sun_path + 1);
+		close(sock);
 		return -1;
 	}
 
-- 
2.7.4



More information about the CRIU mailing list