diff --git a/kernel/exit.c b/kernel/exit.c
index 3f2182ccf1875818c22ddc9395591769413fb54c..df2eee9c68cee980a3a75862e0787fcb019ffa5b 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -774,6 +774,7 @@ static void exit_notify(struct task_struct *tsk)
 	 *	jobs, send them a SIGHUP and then a SIGCONT.  (POSIX 3.2.2.2)
 	 */
 	forget_original_parent(tsk);
+	exit_task_namespaces(tsk);
 
 	write_lock_irq(&tasklist_lock);
 	/*
@@ -984,7 +985,6 @@ fastcall NORET_TYPE void do_exit(long code)
 		module_put(tsk->binfmt->module);
 
 	proc_exit_connector(tsk);
-	exit_task_namespaces(tsk);
 	exit_notify(tsk);
 #ifdef CONFIG_NUMA
 	mpol_free(tsk->mempolicy);