From: Paul Jackson mmput() inside tasklist_lock() can deadlock (thanks, Andrew). To fix, move the range check before getting the mm, so the mm doesn't have to be mmput if the check failed. Also the BUG() was excessively cruel (panics) for this case. Even though "it can't happen", still it is easy to carry on and keep the kernel healthy, at the penalty of not placing memory exactly where the user expected. Signed-off-by: Paul Jackson Signed-off-by: Andrew Morton --- kernel/cpuset.c | 14 +++++--------- 1 files changed, 5 insertions(+), 9 deletions(-) diff -puN kernel/cpuset.c~cpuset-rebind-vma-mempolicies-fix-fix kernel/cpuset.c --- devel/kernel/cpuset.c~cpuset-rebind-vma-mempolicies-fix-fix 2005-12-10 02:47:10.000000000 -0800 +++ devel-akpm/kernel/cpuset.c 2005-12-10 02:47:10.000000000 -0800 @@ -883,20 +883,16 @@ static int update_nodemask(struct cpuset do_each_thread(g, p) { struct mm_struct *mm; + if (n >= ntasks) { + printk(KERN_WARNING + "Cpuset mempolicy rebind incomplete.\n"); + continue; + } if (p->cpuset != cs) continue; mm = get_task_mm(p); if (!mm) continue; - if (n >= ntasks) { - if (printk_ratelimit()) { - printk (KERN_ERR - "Cpuset mempolicy rebind failed.\n"); - BUG(); - } - mmput(mm); - continue; - } mmarray[n++] = mm; } while_each_thread(g, p); write_unlock_irq(&tasklist_lock); _