[CRIU] [crtools-bot for Kir Kolyshkin ] dump_one_task(): do not leak opened pid_dir fd

Cyrill Gorcunov gorcunov at openvz.org
Fri Feb 17 01:46:37 EST 2012


The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
------>
commit 3116e3e9303db3611d503690367713bee69d8ff9
Author: Kir Kolyshkin <kir at openvz.org>
Date:   Fri Feb 17 01:39:32 2012 +0400

    dump_one_task(): do not leak opened pid_dir fd
    
    Make sure we close it
    
    Signed-off-by: Kir Kolyshkin <kir at openvz.org>
    Signed-off-by: Cyrill Gorcunov <gorcunov 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;
 }


More information about the CRIU mailing list