From a19e945f6e40f49bbb11adbd16c5932bd7d56ab4 Mon Sep 17 00:00:00 2001 From: Andrey Vagin Date: Fri, 31 Oct 2014 17:50:46 +0300 Subject: [PATCH] restore: don't leak a transport socket 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 Signed-off-by: Pavel Emelyanov --- files.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/files.c b/files.c index 3bd5830f1..f009e7d64 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)