[CRIU] [PATCH v2] image: potential fd leak in err case

Libo Chen clbchenlibo.chen at huawei.com
Thu May 16 20:56:20 EDT 2013


without this patch, fd will not be freeed

* Changelog from v1:
	* just free fd, no crt.ids

Signed-off-by: Libo Chen <libo.chen at huawei.com>
---
 image.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/image.c b/image.c
index 918a8f6..724ab1f 100644
--- a/image.c
+++ b/image.c
@@ -74,8 +74,10 @@ int write_img_inventory(void)

 	crt.state = TASK_ALIVE;
 	crt.pid.real = getpid();
-	if (get_task_ids(&crt))
+	if (get_task_ids(&crt)){
+		close(fd);
 		return -1;
+	}

 	he.root_ids = crt.ids;

-- 
1.7.10.4



More information about the CRIU mailing list