From: Oleg Nesterov Date: Mon, 26 Jun 2006 07:26:01 +0000 (-0700) Subject: [PATCH] simplify/fix first_tid() X-Git-Tag: v2.6.18-rc1~744 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a872ff0cb2218dc9688b990c5ccda064dc40946b;p=pandora-kernel.git [PATCH] simplify/fix first_tid() first_tid: /* If nr exceeds the number of threads there is nothing todo */ if (nr) { if (nr >= get_nr_threads(leader)) goto done; } This is not reliable: sub-threads can exit after this check, so the 'for' loop below can overlap and proc_task_readdir() can return an already filldir'ed dirents. for (; pos && pid_alive(pos); pos = next_thread(pos)) { if (--nr > 0) continue; Off-by-one error, will return 'leader' when nr == 1. This patch tries to fix these problems and simplify the code. Signed-off-by: Oleg Nesterov Cc: "Eric W. Biederman" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Reading git-diff-tree failed