[CRIU] [PATCH] cr-check: fix pipe fd leak

Libo Chen clbchenlibo.chen at huawei.com
Fri Apr 26 00:49:04 EDT 2013


fix fdinfo leak.

Signed-off-by: Libo Chen <libo.chen at huawei.com>
---
 cr-check.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/cr-check.c b/cr-check.c
index f19bc4f..ddaa429 100644
--- a/cr-check.c
+++ b/cr-check.c
@@ -379,18 +379,23 @@ static int check_unaligned_vmsplice(void)
 	ret = pipe(p);
 	if (ret < 0) {
 		pr_perror("Can't create pipe");
-		return -1;
+		return ret;
 	}
 	iov.iov_base = &buf;
 	iov.iov_len = sizeof(buf);
 	ret = vmsplice(p[1], &iov, 1, SPLICE_F_GIFT | SPLICE_F_NONBLOCK);
 	if (ret < 0) {
 		pr_perror("Unaligned vmsplice doesn't work");
-		return -1;
+		goto err;
 	}

 	pr_info("Unaligned vmsplice works OK\n");
-	return 0;
+	ret = 0;
+err:
+	close(p[0]);
+	close(p[1]);
+
+	return ret;
 }

 #ifndef SO_GET_FILTER
-- 
1.7.10.4




More information about the CRIU mailing list