Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a6f5e06378970a2687332c2d54046245fcff1e7e
Commit:     a6f5e06378970a2687332c2d54046245fcff1e7e
Parent:     b460cbc581a53cc088ceba80608021dd49c63c43
Author:     Sukadev Bhattiprolu <[EMAIL PROTECTED]>
AuthorDate: Thu Oct 18 23:39:53 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Fri Oct 19 11:53:37 2007 -0700

    pid namespaces: move alloc_pid() to copy_process()
    
    Move alloc_pid() into copy_process().  This will keep all pid and pid
    namespace code together and simplify error handling when we support multiple
    pid namespaces.
    
    Signed-off-by: Sukadev Bhattiprolu <[EMAIL PROTECTED]>
    Cc: Pavel Emelianov <[EMAIL PROTECTED]>
    Cc: Eric W. Biederman <[EMAIL PROTECTED]>
    Cc: Cedric Le Goater <[EMAIL PROTECTED]>
    Cc: Dave Hansen <[EMAIL PROTECTED]>
    Cc: Serge Hallyn <[EMAIL PROTECTED]>
    Cc: Herbert Poetzel <[EMAIL PROTECTED]>
    Cc: Kirill Korotaev <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 kernel/fork.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/kernel/fork.c b/kernel/fork.c
index fd65bca..2deaf48 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1040,6 +1040,12 @@ static struct task_struct *copy_process(unsigned long 
clone_flags,
        if (p->binfmt && !try_module_get(p->binfmt->module))
                goto bad_fork_cleanup_put_domain;
 
+       if (pid != &init_struct_pid) {
+               pid = alloc_pid();
+               if (!pid)
+                       goto bad_fork_put_binfmt_module;
+       }
+
        p->did_exec = 0;
        delayacct_tsk_init(p);  /* Must remain after dup_task_struct() */
        copy_flags(clone_flags, p);
@@ -1331,6 +1337,9 @@ bad_fork_cleanup_cgroup:
        cgroup_exit(p, cgroup_callbacks_done);
 bad_fork_cleanup_delays_binfmt:
        delayacct_tsk_free(p);
+       if (pid != &init_struct_pid)
+               free_pid(pid);
+bad_fork_put_binfmt_module:
        if (p->binfmt)
                module_put(p->binfmt->module);
 bad_fork_cleanup_put_domain:
@@ -1395,19 +1404,16 @@ long do_fork(unsigned long clone_flags,
 {
        struct task_struct *p;
        int trace = 0;
-       struct pid *pid = alloc_pid();
        long nr;
 
-       if (!pid)
-               return -EAGAIN;
-       nr = pid->nr;
        if (unlikely(current->ptrace)) {
                trace = fork_traceflag (clone_flags);
                if (trace)
                        clone_flags |= CLONE_PTRACE;
        }
 
-       p = copy_process(clone_flags, stack_start, regs, stack_size, 
parent_tidptr, child_tidptr, pid);
+       p = copy_process(clone_flags, stack_start, regs, stack_size,
+                       parent_tidptr, child_tidptr, NULL);
        /*
         * Do this prior waking up the new thread - the thread pointer
         * might get invalid after that point, if the thread exits quickly.
@@ -1415,6 +1421,8 @@ long do_fork(unsigned long clone_flags,
        if (!IS_ERR(p)) {
                struct completion vfork;
 
+               nr = pid_nr(task_pid(p));
+
                if (clone_flags & CLONE_VFORK) {
                        p->vfork_done = &vfork;
                        init_completion(&vfork);
@@ -1448,7 +1456,6 @@ long do_fork(unsigned long clone_flags,
                        }
                }
        } else {
-               free_pid(pid);
                nr = PTR_ERR(p);
        }
        return nr;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to