diff options
Diffstat (limited to 'kernel/exit.c')
-rw-r--r-- | kernel/exit.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/kernel/exit.c b/kernel/exit.c index 85a83c831856..0ef4673e351b 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -640,24 +640,23 @@ retry: | |||
640 | assign_new_owner: | 640 | assign_new_owner: |
641 | BUG_ON(c == p); | 641 | BUG_ON(c == p); |
642 | get_task_struct(c); | 642 | get_task_struct(c); |
643 | read_unlock(&tasklist_lock); | ||
644 | down_write(&mm->mmap_sem); | ||
643 | /* | 645 | /* |
644 | * The task_lock protects c->mm from changing. | 646 | * The task_lock protects c->mm from changing. |
645 | * We always want mm->owner->mm == mm | 647 | * We always want mm->owner->mm == mm |
646 | */ | 648 | */ |
647 | task_lock(c); | 649 | task_lock(c); |
648 | /* | ||
649 | * Delay read_unlock() till we have the task_lock() | ||
650 | * to ensure that c does not slip away underneath us | ||
651 | */ | ||
652 | read_unlock(&tasklist_lock); | ||
653 | if (c->mm != mm) { | 650 | if (c->mm != mm) { |
654 | task_unlock(c); | 651 | task_unlock(c); |
652 | up_write(&mm->mmap_sem); | ||
655 | put_task_struct(c); | 653 | put_task_struct(c); |
656 | goto retry; | 654 | goto retry; |
657 | } | 655 | } |
658 | cgroup_mm_owner_callbacks(mm->owner, c); | 656 | cgroup_mm_owner_callbacks(mm->owner, c); |
659 | mm->owner = c; | 657 | mm->owner = c; |
660 | task_unlock(c); | 658 | task_unlock(c); |
659 | up_write(&mm->mmap_sem); | ||
661 | put_task_struct(c); | 660 | put_task_struct(c); |
662 | } | 661 | } |
663 | #endif /* CONFIG_MM_OWNER */ | 662 | #endif /* CONFIG_MM_OWNER */ |