]> git.karo-electronics.de Git - karo-tx-linux.git/commit
[PATCH] simplify/fix first_tid()
authorOleg Nesterov <oleg@tv-sign.ru>
Mon, 26 Jun 2006 07:26:01 +0000 (00:26 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 26 Jun 2006 16:58:26 +0000 (09:58 -0700)
commita872ff0cb2218dc9688b990c5ccda064dc40946b
treeff94ae63e668f0229fc7aeed220def7e9708db3a
parentcc288738c9ae3c64d3c50b86604044d1f6d22941
[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 <oleg@tv-sign.ru>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/proc/base.c