[CRIU] [PATCH] parasite: take into account the fact that a file descriptor can be zero

Andrey Vagin avagin at openvz.org
Tue Sep 3 06:57:07 EDT 2013


6. Condition "rst > 0", taking false branch
7. off_by_one: Testing whether handle "rst" is strictly greater than
   zero is suspicious. Did you intend to include equality with zero?
   "rst" leaks when it is zero.

CID 1072986 (#3 of 4): Resource leak (RESOURCE_LEAK)
12. leaked_handle: Handle variable "rst" going out of scope leaks the
handle.

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

diff --git a/parasite-syscall.c b/parasite-syscall.c
index 598f213..00330ad 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -360,7 +360,7 @@ static int prepare_tsock(struct parasite_ctl *ctl, pid_t pid,
 		if (ssock < 0)
 			pr_perror("Can't create socket");
 
-		if (rst > 0 && restore_ns(rst, &net_ns_desc) < 0)
+		if (rst >= 0 && restore_ns(rst, &net_ns_desc) < 0)
 			return -1;
 		if (ssock < 0)
 			return -1;
-- 
1.8.3.1



More information about the CRIU mailing list