diff --git a/mm/memcontrol.c b/mm/memcontrol.c index c92bcfc5466e15456949d0d7b577835b550036ab..47b36fea7e1f85bdb526c5406f6cc2f7db1d3b63 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1787,11 +1787,11 @@ static void mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask, struct task_struct *chosen = NULL; /* - * If current has a pending SIGKILL, then automatically select it. The - * goal is to allow it to allocate so that it may quickly exit and free - * its memory. + * If current has a pending SIGKILL or is exiting, then automatically + * select it. The goal is to allow it to allocate so that it may + * quickly exit and free its memory. */ - if (fatal_signal_pending(current)) { + if (fatal_signal_pending(current) || current->flags & PF_EXITING) { set_thread_flag(TIF_MEMDIE); return; }