files: don't leak a socket in error cases

Submitted by Andrei Vagin on Dec. 8, 2016, 9:50 p.m.

Details

Message ID 1481233834-12960-1-git-send-email-avagin@openvz.org
State Accepted
Series "files: don't leak a socket in error cases"
Commit f8abfe2d25bb33aafe11ccd05e700477e530ff73
Headers show

Commit Message

Andrei Vagin Dec. 8, 2016, 9:50 p.m.
From: Andrei Vagin <avagin@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@virtuozzo.com>
---
 criu/files.c | 1 +
 1 file changed, 1 insertion(+)

Patch hide | download patch | download mbox

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;
 	}
 

Comments

Pavel Emelianov Dec. 14, 2016, 3:29 p.m.
Applied