Skip to content

Commit a689539

Browse files
DerDakontorvalds
authored andcommitted
kernel/fork.c: simplify copy_mm()
All this can happen without a single goto. Link: https://lkml.kernel.org/r/2072685.XptgVkyDqn@devpool47 Signed-off-by: Rolf Eike Beer <eb@emlix.com> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 5449162 commit a689539

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

‎kernel/fork.c‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,6 @@ static struct mm_struct *dup_mm(struct task_struct *tsk,
13961396
static int copy_mm(unsigned long clone_flags, struct task_struct *tsk)
13971397
{
13981398
struct mm_struct *mm, *oldmm;
1399-
int retval;
14001399

14011400
tsk->min_flt = tsk->maj_flt = 0;
14021401
tsk->nvcsw = tsk->nivcsw = 0;
@@ -1423,21 +1422,15 @@ static int copy_mm(unsigned long clone_flags, struct task_struct *tsk)
14231422
if (clone_flags & CLONE_VM) {
14241423
mmget(oldmm);
14251424
mm = oldmm;
1426-
goto good_mm;
1425+
} else {
1426+
mm = dup_mm(tsk, current->mm);
1427+
if (!mm)
1428+
return -ENOMEM;
14271429
}
14281430

1429-
retval = -ENOMEM;
1430-
mm = dup_mm(tsk, current->mm);
1431-
if (!mm)
1432-
goto fail_nomem;
1433-
1434-
good_mm:
14351431
tsk->mm = mm;
14361432
tsk->active_mm = mm;
14371433
return 0;
1438-
1439-
fail_nomem:
1440-
return retval;
14411434
}
14421435

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

0 commit comments

Comments
 (0)