From patchwork Mon Jan 15 06:11:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li kunyu X-Patchwork-Id: 188030 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp1525317dyc; Sun, 14 Jan 2024 22:12:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IFlN5jpKppE3HCfOC0+epVjv6t3qFYWag6NILbbKBNZGDU7RcrH09zm4AZDcQxIJtB8jIYS X-Received: by 2002:a05:6402:350e:b0:558:6cc:d5d6 with SMTP id b14-20020a056402350e00b0055806ccd5d6mr2885626edd.11.1705299124015; Sun, 14 Jan 2024 22:12:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705299123; cv=none; d=google.com; s=arc-20160816; b=wyFdKyhIsK0yQHUV7xRCCcvLW7E/aoLwBF7Kboe+wYcNtQy0oQhZLQRvhqBZp9HbHm 1Bnh8agZj+Nc6R+mSGBM/746SjRNumRpzaVz5CCqK23JmQ2FhtuiyVXIHZygoCGeVu2T 9pMLGLS3rBrNqJcfBsAUmUfMCnJ8KZeeAqiQ+/sI6VLBFBiA28AlqvJSw1FAMDKUbDny /0/5jNMjv/dO+wNZS67vwa1LikqxtGU95Uz7gAVR5w2awmSY72ICim7q3KTQDZv5DoFQ qaDxtOvDE3AWRN4xh1J+p0I0tR0MV7pFj41/k87rI/XeI9ZqPqLMwAuxVnUd+V7t+Lqi 9XPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from; bh=//BBB8xS0KmBLXU/JDm3fWu/Q23c30g9Vnvny2OXdBc=; fh=MbRBm2uZ/HDKvyyN0Il4TJG2sir6EBgK5E27/nnGWXQ=; b=mEKI61d/2phZ2vacEPXm7VwP7GX0he6/07qQjMBF5ACbQ4grdOLPLlMDD+zbBcRXjm kXZpK1mhO5KgCgv50xt+F7IDxAUkKNYVnzr6wuzBYIBmA3DPq8NtXLwfbzSaMKbIaIxb mj3NJrCbaDXo1GJgmsYbpbbMny7fIGBzDEc7lMXLIleokKQr8aDiXERzgIJEtRcgdtg5 GFsDJA2rugrGNiRXggJ4C20H3W2u7DsqDM6AF3OpusyHnoUQmAqAnCu2FBWS+V1Pu4wW KloqmF3Mc3vAA8MtQZKIHB0nyt62VKzTq8O3A1dBCkPHqzLWiBuXI/WFnTFw6Y+iZyhY rZTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-25652-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25652-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id fj12-20020a0564022b8c00b005593a62de2fsi812906edb.153.2024.01.14.22.12.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jan 2024 22:12:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25652-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-25652-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25652-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9E4D41F21652 for ; Mon, 15 Jan 2024 06:12:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB7DE5233; Mon, 15 Jan 2024 06:11:51 +0000 (UTC) Received: from mail.nfschina.com (unknown [42.101.60.195]) by smtp.subspace.kernel.org (Postfix) with SMTP id 2D3D53C0E for ; Mon, 15 Jan 2024 06:11:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nfschina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nfschina.com Received: from localhost.localdomain (unknown [219.141.250.2]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPA id F261D602521A5; Mon, 15 Jan 2024 14:11:33 +0800 (CST) X-MD-Sfrom: kunyu@nfschina.com X-MD-SrcIP: 219.141.250.2 From: Li kunyu To: linux-kernel@vger.kernel.org Cc: Li kunyu Subject: [PATCH] utsname: Optimize clone_uts_ns() Date: Mon, 15 Jan 2024 14:11:27 +0800 Message-Id: <20240115061127.30836-1-kunyu@nfschina.com> X-Mailer: git-send-email 2.18.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788135734069247379 X-GMAIL-MSGID: 1788135734069247379 Optimize the err variable assignment location so that the err variable is manually modified when an error occurs. Signed-off-by: Li kunyu --- kernel/utsname.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/utsname.c b/kernel/utsname.c index b1ac3ca870f24..f55568e00927c 100644 --- a/kernel/utsname.c +++ b/kernel/utsname.c @@ -49,15 +49,17 @@ static struct uts_namespace *clone_uts_ns(struct user_namespace *user_ns, struct ucounts *ucounts; int err; - err = -ENOSPC; ucounts = inc_uts_namespaces(user_ns); - if (!ucounts) + if (!ucounts) { + err = -ENOSPC; goto fail; + } - err = -ENOMEM; ns = create_uts_ns(); - if (!ns) + if (!ns) { + err = -ENOMEM; goto fail_dec; + } err = ns_alloc_inum(&ns->ns); if (err)