[CRIU] [PATCH 4/8] restore: don't leak a transport socket
Andrey Vagin
avagin at openvz.org
Fri Oct 31 07:50:46 PDT 2014
CID 73354 (#1 of 1): Resource leak (RESOURCE_LEAK)
9. leaked_handle: Handle variable sock going out of scope leaks the handle
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
files.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/files.c b/files.c
index 3bd5830..f009e7d 100644
--- a/files.c
+++ b/files.c
@@ -749,18 +749,21 @@ static int open_transport_fd(int pid, struct fdinfo_list_entry *fle)
ret = bind(sock, &saddr, sun_len);
if (ret < 0) {
pr_perror("Can't bind unix socket %s", saddr.sun_path + 1);
- return -1;
+ goto err;
}
ret = reopen_fd_as(fle->fe->fd, sock);
if (ret < 0)
- return -1;
+ goto err;
pr_info("\t\tWake up fdinfo pid=%d fd=%d\n", fle->pid, fle->fe->fd);
futex_set_and_wake(&fle->real_pid, getpid());
want_recv_stage();
return 0;
+err:
+ close(sock);
+ return -1;
}
int send_fd_to_peer(int fd, struct fdinfo_list_entry *fle, int sock)
--
1.9.3
More information about the CRIU
mailing list