[CRIU] [PATCH 14/18] kerndat: don't leak a file descriptor

Andrei Vagin avagin at openvz.org
Thu Nov 9 22:21:08 MSK 2017


From: Andrei Vagin <avagin at virtuozzo.com>

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

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 criu/kerndat.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/criu/kerndat.c b/criu/kerndat.c
index 219bfd62c..26d7d0df9 100644
--- a/criu/kerndat.c
+++ b/criu/kerndat.c
@@ -808,6 +808,7 @@ static int kerndat_try_load_cache(void)
 	ret = read(fd, &kdat, sizeof(kdat));
 	if (ret < 0) {
 		pr_perror("Can't read kdat cache");
+		close(fd);
 		return -1;
 	}
 
-- 
2.13.6



More information about the CRIU mailing list