[CRIU] [PATCH] restore: don't close mnt_ns_fd twice

Andrey Vagin avagin at openvz.org
Mon Oct 5 06:01:24 PDT 2015


From: Andrew Vagin <avagin at openvz.org>

CID 152114 (#1 of 1): Double close (USE_AFTER_FREE)
27. double_close: Calling try_clean_remaps(int) closes handle mnt_ns_fd which has already been closed.

Signed-off-by: Andrew Vagin <avagin at openvz.org>
---
 cr-restore.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cr-restore.c b/cr-restore.c
index 861fe09..9781fc2 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1858,12 +1858,14 @@ static int restore_root_task(struct pstree_item *init)
 	 */
 	task_entries->nr_threads -= atomic_read(&task_entries->nr_zombies);
 
-	if (mnt_ns_fd >= 0)
+	if (mnt_ns_fd >= 0) {
 		/*
 		 * Don't try_clean_remaps here, since restore went OK
 		 * and all ghosts were removed by the openers.
 		 */
 		close(mnt_ns_fd);
+		mnt_ns_fd = -1;
+	}
 	cleanup_mnt_ns();
 
 	ret = stop_usernsd();
-- 
2.4.3



More information about the CRIU mailing list