]> err.no Git - linux-2.6/commitdiff
Fix clear_refs_write() use of struct mm_walk
authorAndrew Morton <akpm@linux-foundation.org>
Sat, 5 Jul 2008 19:29:05 +0000 (12:29 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 5 Jul 2008 20:07:56 +0000 (13:07 -0700)
Don't use a static entry, so as to prevent races during concurrent use
of this function.

Reported-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Matt Mackall <mpm@selenic.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/proc/task_mmu.c

index ab8ccc9d14ff6df10abdd715076d870dafb32a85..05053d701ac5d515ef17804c9162e85ac6971e2b 100644 (file)
@@ -476,10 +476,10 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
                return -ESRCH;
        mm = get_task_mm(task);
        if (mm) {
-               static struct mm_walk clear_refs_walk;
-               memset(&clear_refs_walk, 0, sizeof(clear_refs_walk));
-               clear_refs_walk.pmd_entry = clear_refs_pte_range;
-               clear_refs_walk.mm = mm;
+               struct mm_walk clear_refs_walk = {
+                       .pmd_entry = clear_refs_pte_range,
+                       .mm = mm,
+               };
                down_read(&mm->mmap_sem);
                for (vma = mm->mmap; vma; vma = vma->vm_next) {
                        clear_refs_walk.private = vma;