Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7372612pxb; Thu, 18 Feb 2021 08:24:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDOXFmta7p0HAztO/VTQhZYeca8ecJdWz9NULIVrq7+ByuZgI2vkcf3qwolFUz58INY0r+ X-Received: by 2002:a05:6402:3589:: with SMTP id y9mr4935595edc.344.1613665476510; Thu, 18 Feb 2021 08:24:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613665476; cv=none; d=google.com; s=arc-20160816; b=QqoBcOiBsTfkWE9e1LoC5THXdbnoL1Ei9pBNcb7ZekPVYi43/nw7210Zj2Ndvpak4g ZQrSCcveZtf7jPt+jnXudsU0awaytNkGHMjJzntPJrcVtJ07/Aij0oXcaYmWZ4rzMUBy nrykMthqEYf2M6Nd9OuDTHDS4raS88nObD7G54Ds9emKkmAxsbYdiJxkVhDBUcdWUAkP VaxQJ6TgFQuEtbAwHABKeBNw/6w7Lb9M1/EfXOusmaA0XIP4gQgK1os7wMEDloyGCEve UUY5WCp+SnTYCq+6DnWXTVwVNUyHsFSuGGFznV0kPh/HXQLJWopY+k9/ydZsWH54R2iy oBPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:message-id:date:subject:cc:to:from; bh=QzgMM73E+iiYsevzDASfid1iFJnA65Oz32oBLO1HBs0=; b=SGczxSRjxR0AfIOJSozDejj+CQgwht1mk7Q4bitziVtv8pddja/jagnjyk4zbetyzn B/WXnVE7X9ycYyKdn0pm+X2MsVHHm18csbz+1sCPT/25CxbI3J/70IYUvZWdH2sNt5Ub aEAmZorKF7X8DG5V1J5OU1uiYUWaIL+eyhMiCCd9ZDcw5lUJ5vRlAsEgme8wk3WVNGeN f6WUwUtsZdg2tlzxp7604ufqxQ3mRf+gc+TznlkwjlrK7g+vU0ISBaxNzyUZSeEPmf3t 04+ITVVmhgspI4Wp8XGgnr0dXSBVotkmQr9x4Hd1O86i3EPvxanyX0OIpbbb1pIgLoqJ Ow5A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a20si4229956ejg.257.2021.02.18.08.24.12; Thu, 18 Feb 2021 08:24:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230099AbhBRQXY convert rfc822-to-8bit (ORCPT + 99 others); Thu, 18 Feb 2021 11:23:24 -0500 Received: from mx1.emlix.com ([136.243.223.33]:57522 "EHLO mx1.emlix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231314AbhBRNi7 (ORCPT ); Thu, 18 Feb 2021 08:38:59 -0500 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 Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) -- 2.30.0 -- Rolf Eike Beer, emlix GmbH, http://www.emlix.com Fon +49 551 30664-0, Fax +49 551 30664-11 Gothaer Platz 3, 37083 Göttingen, Germany Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160 Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055 emlix - smart embedded open source