diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 8ad35aa45436cc309cefe7b2796e085043c2174f..5ba743aaba87c0b883a66c7339ac9e83bc94e520 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -552,8 +552,9 @@ void oom_kill_process(struct oom_control *oc, struct task_struct *p, victim = p; } - /* mm cannot safely be dereferenced after task_unlock(victim) */ + /* Get a reference to safely compare mm after task_unlock(victim) */ mm = victim->mm; + atomic_inc(&mm->mm_count); /* * We should send SIGKILL before setting TIF_MEMDIE in order to prevent * the OOM victim from depleting the memory reserves from the user @@ -591,6 +592,7 @@ void oom_kill_process(struct oom_control *oc, struct task_struct *p, } rcu_read_unlock(); + mmdrop(mm); put_task_struct(victim); } #undef K