[CRIU] [PATCH 1/5] dump_one_task(): do not leak opened pid_dir fd

Kir Kolyshkin kir at openvz.org
Thu Feb 16 16:39:32 EST 2012


Make sure we close it

Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 cr-dump.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/cr-dump.c b/cr-dump.c
index 3766d34..c39bbce 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -1177,13 +1177,13 @@ static int dump_one_task(struct pstree_item *item, struct cr_fdset *cr_fdset)
 
 	if (item->state == TASK_STOPPED) {
 		pr_err("Stopped tasks are not supported\n");
-		goto err;
+		goto err_free;
 	}
 
 	pid_dir = open_pid_proc(pid);
 	if (pid_dir < 0) {
 		pr_perror("Can't open %d proc dir", pid);
-		goto err;
+		goto err_free;
 	}
 
 	pr_info("Obtainting task stat ... ");
@@ -1272,9 +1272,11 @@ static int dump_one_task(struct pstree_item *item, struct cr_fdset *cr_fdset)
 
 	free_mappings(&vma_area_list);
 
-	return dump_task_threads(item);
+	ret = dump_task_threads(item);
 
 err:
+	close(pid_dir);
+err_free:
 	free_mappings(&vma_area_list);
 	return ret;
 }
-- 
1.7.7.6



More information about the CRIU mailing list