simplify copy_mm()
diff mbox series

Message ID 2072685.XptgVkyDqn@devpool47
State Accepted
Commit a6895399380ab58d9efd0a0bec2fcb98d77e20bd
Headers show
Series
  • simplify copy_mm()
Related show

Commit Message

Rolf Eike Beer Feb. 18, 2021, 12:37 p.m. UTC
All this can happen without a single goto.

Signed-off-by: Rolf Eike Beer <eb@emlix.com>
---
 kernel/fork.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

Patch
diff mbox series

diff --git a/kernel/fork.c b/kernel/fork.c
index d66cd1014211..1cad8c622b34 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1382,7 +1382,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;
@@ -1409,21 +1408,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)