diff --git a/kernel/exit.c b/kernel/exit.c
index 4a280856acd2e8db9252c3e3f340b499b7edafc2..3d759c98fb1196d2b25dc733ead29406fb38dca3 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -957,6 +957,7 @@ fastcall NORET_TYPE void do_exit(long code)
 	preempt_disable();
 	BUG_ON(tsk->flags & PF_DEAD);
 	tsk->flags |= PF_DEAD;
+	tsk->state = EXIT_DEAD;
 
 	schedule();
 	BUG();
diff --git a/kernel/sched.c b/kernel/sched.c
index 155a33da7aa76ca733977c9b934042551ca2e7f0..e1646b044b69470c089a318765cd87e22a60caee 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3348,9 +3348,6 @@ need_resched_nonpreemptible:
 
 	spin_lock_irq(&rq->lock);
 
-	if (unlikely(prev->flags & PF_DEAD))
-		prev->state = EXIT_DEAD;
-
 	switch_count = &prev->nivcsw;
 	if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
 		switch_count = &prev->nvcsw;