kernel/fork.c: check error and return early
Thus reducing one indentation level while maintaining the same rationale. Link: http://lkml.kernel.org/r/20171117002929.5155-1-marcos.souza.org@gmail.com Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com> Acked-by: Michal Hocko <mhocko@suse.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
63300eddb1
commit
9f5325aa37
@ -2062,6 +2062,8 @@ long _do_fork(unsigned long clone_flags,
|
|||||||
int __user *child_tidptr,
|
int __user *child_tidptr,
|
||||||
unsigned long tls)
|
unsigned long tls)
|
||||||
{
|
{
|
||||||
|
struct completion vfork;
|
||||||
|
struct pid *pid;
|
||||||
struct task_struct *p;
|
struct task_struct *p;
|
||||||
int trace = 0;
|
int trace = 0;
|
||||||
long nr;
|
long nr;
|
||||||
@ -2087,43 +2089,40 @@ long _do_fork(unsigned long clone_flags,
|
|||||||
p = copy_process(clone_flags, stack_start, stack_size,
|
p = copy_process(clone_flags, stack_start, stack_size,
|
||||||
child_tidptr, NULL, trace, tls, NUMA_NO_NODE);
|
child_tidptr, NULL, trace, tls, NUMA_NO_NODE);
|
||||||
add_latent_entropy();
|
add_latent_entropy();
|
||||||
|
|
||||||
|
if (IS_ERR(p))
|
||||||
|
return PTR_ERR(p);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do this prior waking up the new thread - the thread pointer
|
* Do this prior waking up the new thread - the thread pointer
|
||||||
* might get invalid after that point, if the thread exits quickly.
|
* might get invalid after that point, if the thread exits quickly.
|
||||||
*/
|
*/
|
||||||
if (!IS_ERR(p)) {
|
trace_sched_process_fork(current, p);
|
||||||
struct completion vfork;
|
|
||||||
struct pid *pid;
|
|
||||||
|
|
||||||
trace_sched_process_fork(current, p);
|
pid = get_task_pid(p, PIDTYPE_PID);
|
||||||
|
nr = pid_vnr(pid);
|
||||||
|
|
||||||
pid = get_task_pid(p, PIDTYPE_PID);
|
if (clone_flags & CLONE_PARENT_SETTID)
|
||||||
nr = pid_vnr(pid);
|
put_user(nr, parent_tidptr);
|
||||||
|
|
||||||
if (clone_flags & CLONE_PARENT_SETTID)
|
if (clone_flags & CLONE_VFORK) {
|
||||||
put_user(nr, parent_tidptr);
|
p->vfork_done = &vfork;
|
||||||
|
init_completion(&vfork);
|
||||||
if (clone_flags & CLONE_VFORK) {
|
get_task_struct(p);
|
||||||
p->vfork_done = &vfork;
|
|
||||||
init_completion(&vfork);
|
|
||||||
get_task_struct(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
wake_up_new_task(p);
|
|
||||||
|
|
||||||
/* forking complete and child started to run, tell ptracer */
|
|
||||||
if (unlikely(trace))
|
|
||||||
ptrace_event_pid(trace, pid);
|
|
||||||
|
|
||||||
if (clone_flags & CLONE_VFORK) {
|
|
||||||
if (!wait_for_vfork_done(p, &vfork))
|
|
||||||
ptrace_event_pid(PTRACE_EVENT_VFORK_DONE, pid);
|
|
||||||
}
|
|
||||||
|
|
||||||
put_pid(pid);
|
|
||||||
} else {
|
|
||||||
nr = PTR_ERR(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wake_up_new_task(p);
|
||||||
|
|
||||||
|
/* forking complete and child started to run, tell ptracer */
|
||||||
|
if (unlikely(trace))
|
||||||
|
ptrace_event_pid(trace, pid);
|
||||||
|
|
||||||
|
if (clone_flags & CLONE_VFORK) {
|
||||||
|
if (!wait_for_vfork_done(p, &vfork))
|
||||||
|
ptrace_event_pid(PTRACE_EVENT_VFORK_DONE, pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
put_pid(pid);
|
||||||
return nr;
|
return nr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user