[CRIU] [PATCH 2/2] files: don't leak a file descriptor on an error path

Andrey Vagin avagin at openvz.org
Thu Oct 29 05:29:26 PDT 2015


From: Andrew Vagin <avagin at openvz.org>

CID 84652 (#1 of 1): Resource leak (RESOURCE_LEAK)
6. leaked_handle: Handle variable newfd going out of scope leaks the handle.

Signed-off-by: Andrew Vagin <avagin at openvz.org>
---
 files.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/files.c b/files.c
index af1c0f3..da6a5ae 100644
--- a/files.c
+++ b/files.c
@@ -1526,6 +1526,7 @@ int inherit_fd_resolve_clash(int fd)
 	}
 
 	if (close(fd) == -1) {
+		close(newfd);
 		pr_perror("Can't close inherit fd %d", fd);
 		return -1;
 	}
-- 
2.4.3



More information about the CRIU mailing list