From c8f22f96ed86c16d22e61da17deab6cf7b00ff83 Mon Sep 17 00:00:00 2001 From: Andrey Vagin Date: Tue, 3 Sep 2013 14:58:13 +0400 Subject: [PATCH] parasite: take into account the fact that a file descriptor can be zero 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 Signed-off-by: Pavel Emelyanov --- parasite-syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parasite-syscall.c b/parasite-syscall.c index 598f213a4..00330ad2e 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;