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

Andrey Vagin avagin at openvz.org
Fri May 1 04:06:32 PDT 2015


288             if (flock(fd, LOCK_SH)) {
289                     pr_perror("Can't take a lock\n");
>>>     CID 92726:  Resource leaks  (RESOURCE_LEAK)
>>>     Handle variable "fd" going out of scope leaks the handle.
290                     return -1;
291             }

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 kerndat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kerndat.c b/kerndat.c
index 6745dbb..583414c 100644
--- a/kerndat.c
+++ b/kerndat.c
@@ -287,7 +287,7 @@ int kerndat_fdinfo_has_lock()
 
 	if (flock(fd, LOCK_SH)) {
 		pr_perror("Can't take a lock\n");
-		return -1;
+		goto out;
 	}
 
 	pfd = open_proc(PROC_SELF, "fdinfo/%d", fd);
-- 
2.1.0



More information about the CRIU mailing list