Skip to content

Commit

Permalink
kernel/fork.c: simplify copy_mm()
Browse files Browse the repository at this point in the history
All this can happen without a single goto.

Link: https://lkml.kernel.org/r/2072685.XptgVkyDqn@devpool47
Signed-off-by: Rolf Eike Beer <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
DerDakon authored and torvalds committed May 7, 2021
1 parent 5449162 commit a689539
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions kernel/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,6 @@ static struct mm_struct *dup_mm(struct task_struct *tsk,
static int copy_mm(unsigned long clone_flags, struct task_struct *tsk)
{
struct mm_struct *mm, *oldmm;
int retval;

tsk->min_flt = tsk->maj_flt = 0;
tsk->nvcsw = tsk->nivcsw = 0;
Expand All @@ -1423,21 +1422,15 @@ static int copy_mm(unsigned long clone_flags, struct task_struct *tsk)
if (clone_flags & CLONE_VM) {
mmget(oldmm);
mm = oldmm;
goto good_mm;
} else {
mm = dup_mm(tsk, current->mm);
if (!mm)
return -ENOMEM;
}

retval = -ENOMEM;
mm = dup_mm(tsk, current->mm);
if (!mm)
goto fail_nomem;

good_mm:
tsk->mm = mm;
tsk->active_mm = mm;
return 0;

fail_nomem:
return retval;
}

static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
Expand Down

0 comments on commit a689539

Please sign in to comment.