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

From: William Lee Irwin III
Date: Tue Jun 01 2004 - 00:58:20 EST


Split off from suparna's patches:

Correct use_mm()/unuse_mm() to use task_lock() to protect task->mm.

Index: suparna-2.6.7-rc2/fs/aio.c
===================================================================
--- suparna-2.6.7-rc2.orig/fs/aio.c 2004-05-31 22:06:35.788770000 -0700
+++ suparna-2.6.7-rc2/fs/aio.c 2004-05-31 22:08:41.057727000 -0700
@@ -538,19 +538,25 @@

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);
+ task_lock(current);
+ active_mm = current->active_mm;
current->mm = mm;
if (mm != active_mm) {
current->active_mm = mm;
activate_mm(active_mm, mm);
}
+ task_unlock(current);
mmdrop(active_mm);
}

static void unuse_mm(struct mm_struct *mm)
{
+ task_lock(current);
current->mm = NULL;
+ task_unlock(current);
/* active_mm is still 'mm' */
enter_lazy_tlb(mm, current);
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/