[CRIU] [PATCH] seize: don't leak a file descriptor

Andrey Vagin avagin at openvz.org
Mon Jul 18 11:23:19 PDT 2016


From: Andrew Vagin <avagin at virtuozzo.com>

267                     if (stack < 0) {
268                             pr_perror("couldn't log %d's stack", pid);
>>>     CID 164721:  Resource leaks  (RESOURCE_LEAK)
>>>     Variable "f" going out of scope leaks the storage it points to.
269                             return -1;

Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 criu/seize.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/criu/seize.c b/criu/seize.c
index ff95712..9d27e8d 100644
--- a/criu/seize.c
+++ b/criu/seize.c
@@ -266,6 +266,7 @@ static int log_unfrozen_stacks(char *root)
 		stack = open_proc(pid, "stack");
 		if (stack < 0) {
 			pr_perror("couldn't log %d's stack", pid);
+			fclose(f);
 			return -1;
 		}
 
@@ -273,6 +274,7 @@ static int log_unfrozen_stacks(char *root)
 		close(stack);
 		if (ret < 0) {
 			pr_perror("couldn't read %d's stack", pid);
+			fclose(f);
 			return -1;
 		}
 		stackbuf[ret] = '\0';
-- 
2.7.4



More information about the CRIU mailing list