summaryrefslogtreecommitdiff
path: root/kernel/fork.c
diff options
context:
space:
mode:
authorJ. A. Magallon <jamagallon@able.es>2002-02-14 01:33:14 -0800
committerLinus Torvalds <torvalds@penguin.transmeta.com>2002-02-14 01:33:14 -0800
commit8af480ec7955bce446f3f0607abc500bf47a4d34 (patch)
tree96a93d0c6596cdd7fc302caf277f3f7f4d552b62 /kernel/fork.c
parent617ee601252f003f1a3a083e76239fa2b5359b3e (diff)
[PATCH] pid allocator bugfix
This patch fixes a bug in the Linux process ID allocator. It isn't quite SMP safe since it references "last_pid" after releasing the lock protecting it. This can result in two processes getting assigned the same process ID.
Diffstat (limited to 'kernel/fork.c')
-rw-r--r--kernel/fork.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index 3ba556b47705..2d13c18afe25 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -129,6 +129,7 @@ static int get_pid(unsigned long flags)
{
static int next_safe = PID_MAX;
struct task_struct *p;
+ int pid;
if (flags & CLONE_PID)
return current->pid;
@@ -164,9 +165,10 @@ inside:
}
read_unlock(&tasklist_lock);
}
+ pid = last_pid;
spin_unlock(&lastpid_lock);
- return last_pid;
+ return pid;
}
static inline int dup_mmap(struct mm_struct * mm)