Commit 772213c8 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] correct use_mm()/unuse_mm() to use task_lock() to protect ->mm

From: William Lee Irwin III <wli@holomorphy.com>

Split off from suparna's patches:

Correct use_mm()/unuse_mm() to use task_lock() to protect task->mm.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 7746c15f
...@@ -538,19 +538,25 @@ struct kioctx *lookup_ioctx(unsigned long ctx_id) ...@@ -538,19 +538,25 @@ struct kioctx *lookup_ioctx(unsigned long ctx_id)
static void use_mm(struct mm_struct *mm) static void use_mm(struct mm_struct *mm)
{ {
struct mm_struct *active_mm = current->active_mm; struct mm_struct *active_mm;
atomic_inc(&mm->mm_count); atomic_inc(&mm->mm_count);
task_lock(current);
active_mm = current->active_mm;
current->mm = mm; current->mm = mm;
if (mm != active_mm) { if (mm != active_mm) {
current->active_mm = mm; current->active_mm = mm;
activate_mm(active_mm, mm); activate_mm(active_mm, mm);
} }
task_unlock(current);
mmdrop(active_mm); mmdrop(active_mm);
} }
static void unuse_mm(struct mm_struct *mm) static void unuse_mm(struct mm_struct *mm)
{ {
task_lock(current);
current->mm = NULL; current->mm = NULL;
task_unlock(current);
/* active_mm is still 'mm' */ /* active_mm is still 'mm' */
enter_lazy_tlb(mm, current); enter_lazy_tlb(mm, current);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment