From patchwork Thu Feb 18 12:37:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rolf Eike Beer X-Patchwork-Id: 12093521 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DE44C433DB for ; Thu, 18 Feb 2021 12:37:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A2BEE61606 for ; Thu, 18 Feb 2021 12:37:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2BEE61606 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=emlix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 12E4B6B0006; Thu, 18 Feb 2021 07:37:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B60C6B006C; Thu, 18 Feb 2021 07:37:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE5C56B006E; Thu, 18 Feb 2021 07:37:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0115.hostedemail.com [216.40.44.115]) by kanga.kvack.org (Postfix) with ESMTP id D53DA6B0006 for ; Thu, 18 Feb 2021 07:37:14 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 92259181AF5D0 for ; Thu, 18 Feb 2021 12:37:14 +0000 (UTC) X-FDA: 77831338788.25.7FBBDA7 Received: from mx1.emlix.com (mx1.emlix.com [136.243.223.33]) by imf29.hostedemail.com (Postfix) with ESMTP id E7A25139 for ; Thu, 18 Feb 2021 12:37:13 +0000 (UTC) Received: from mailer.emlix.com (unknown [81.20.119.6]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.emlix.com (Postfix) with ESMTPS id 2C08060016; Thu, 18 Feb 2021 13:37:12 +0100 (CET) From: Rolf Eike Beer To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] simplify copy_mm() Date: Thu, 18 Feb 2021 13:37:11 +0100 Message-ID: <2072685.XptgVkyDqn@devpool47> Organization: emlix GmbH MIME-Version: 1.0 X-Stat-Signature: 5u9hwtbs7cmcgqxw6pmqpij8ytomsh3m X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: E7A25139 Received-SPF: none (emlix.com>: No applicable sender policy available) receiver=imf29; identity=mailfrom; envelope-from=""; helo=mx1.emlix.com; client-ip=136.243.223.33 X-HE-DKIM-Result: none/none X-HE-Tag: 1613651833-91088 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: All this can happen without a single goto. Signed-off-by: Rolf Eike Beer --- kernel/fork.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) 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)