[CRIU] [PATCH 2/5] serve_out_fd(): don't leak fd on error

Kir Kolyshkin kir at openvz.org
Tue May 5 15:31:09 PDT 2015


Reported by Coverity, CID 51629.

Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 files.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/files.c b/files.c
index 0f7f107..bf39567 100644
--- a/files.c
+++ b/files.c
@@ -844,12 +844,14 @@ static int serve_out_fd(int pid, int fd, struct file_desc *d)
 
 		if (ret) {
 			pr_err("Can't sent fd %d to %d\n", fd, fle->pid);
-			return -1;
+			goto out;
 		}
 	}
 
+	ret = 0;
+out:
 	close(sock);
-	return 0;
+	return ret;
 }
 
 static int open_fd(int pid, struct fdinfo_list_entry *fle)
-- 
1.9.3



More information about the CRIU mailing list