Messages in this thread Patch in this message | | | Date | Thu, 10 Nov 2011 21:15:31 +0400 | From | Pavel Emelyanov <> | Subject | [PATCH 1/3] pids: Make alloc_pid return error |
| |
Currently the alloc_pid just reports the pid allocation failre and this gets reported as ENOMEM to user. With the clone-with-pid ability the error codes set will be extended and this patch eases this extension.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
--- kernel/fork.c | 5 +++-- kernel/pid.c | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/kernel/fork.c b/kernel/fork.c index 8e6b6f4..45a5f54 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1253,10 +1253,11 @@ static struct task_struct *copy_process(unsigned long clone_flags, goto bad_fork_cleanup_io; if (pid != &init_struct_pid) { - retval = -ENOMEM; pid = alloc_pid(p->nsproxy->pid_ns); - if (!pid) + if (IS_ERR(pid)) { + retval = PTR_ERR(pid); goto bad_fork_cleanup_io; + } } p->pid = pid_nr(pid); diff --git a/kernel/pid.c b/kernel/pid.c index e432057..2d9704c 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -214,7 +214,7 @@ static int alloc_pidmap(struct pid_namespace *pid_ns) } pid = mk_pid(pid_ns, map, offset); } - return -1; + return -ENOMEM; } int next_pidmap(struct pid_namespace *pid_ns, unsigned int last) @@ -281,7 +281,7 @@ struct pid *alloc_pid(struct pid_namespace *ns) { struct pid *pid; enum pid_type type; - int i, nr; + int i, nr = -ENOMEM; struct pid_namespace *tmp; struct upid *upid; @@ -321,7 +321,7 @@ out_free: free_pidmap(pid->numbers + i); kmem_cache_free(ns->pid_cachep, pid); - pid = NULL; + pid = ERR_PTR(nr); goto out; } -- 1.5.5.6
| |