From: Paul Jackson Date: Fri, 31 Mar 2006 10:30:51 +0000 (-0800) Subject: [PATCH] cpuset: unsafe mm reference fix X-Git-Tag: v2.6.17-rc1~83 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2741a559a01e1ba9bf87285569dc1a104d134ecf;p=linux-2.6 [PATCH] cpuset: unsafe mm reference fix Fix unsafe reference to a tasks mm struct, by moving the reference inside of a convenient nearby properly guarded code block. Signed-off-by: Paul Jackson Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 2523a4b6a8..bf42381a41 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c @@ -1183,11 +1183,11 @@ static int attach_task(struct cpuset *cs, char *pidbuf, char **ppathbuf) mm = get_task_mm(tsk); if (mm) { mpol_rebind_mm(mm, &to); + if (is_memory_migrate(cs)) + do_migrate_pages(mm, &from, &to, MPOL_MF_MOVE_ALL); mmput(mm); } - if (is_memory_migrate(cs)) - do_migrate_pages(tsk->mm, &from, &to, MPOL_MF_MOVE_ALL); put_task_struct(tsk); synchronize_rcu(); if (atomic_dec_and_test(&oldcs->count))