From patchwork Mon Jan 15 04:42:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li kunyu X-Patchwork-Id: 188017 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp1500009dyc; Sun, 14 Jan 2024 20:42:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHkMDMJqLKavd84mwiAdtt3eugev/KxUpbodYMzlcTeSlTp0wJ8caqs2hDDvijbP6ZG1o+g X-Received: by 2002:a17:907:160d:b0:a2d:9c1e:9bfc with SMTP id cw13-20020a170907160d00b00a2d9c1e9bfcmr519743ejd.7.1705293751997; Sun, 14 Jan 2024 20:42:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705293751; cv=none; d=google.com; s=arc-20160816; b=eKY4oTRKh3iT2GreJcYPrU0dUERR4qEGOzDCBPh5coV6Rh0CQdVszUjyEY26vuMXEG PcaiAROIaBHhHEDiKB8Rng6zjosCPC8kCmplvW1OcNNm4AisO+kDNWF7r3ivYs3So7S/ UvnByVlihwaW/QHeZDvvzqVWDezjlPXBD2h5XzCUvBGtX9nM46grSqBmv+S7Vyc6ZIQp IhgU0gliU7+BMMQZtARvxN96QaWw1yFcU1mKFgplLRGRXcLWTfmv/Rg8ylS5I6Gm/LnO NJUv9LWJoKtn6uy3AQv02BtPzXTwf0JF3MA3Ot0CYgQm7XDsLVfUtETdKsY7mvAkslFM V6OQ== 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=j4TBV7G+AQFPTdVaM96g6pTRHOITiVKRY602ELXzwUk=; fh=jzlhXQxIiMofIqYydNy0mw+2jkh/EWoR0zilMMm7XvQ=; b=bR7zMjAFUBE5lPWyyWlvf3LBGNnd9szysjCz7DPhneTyDaOyQwbpFJv1DXgj9AfGnW DFR7/ByijxIXfKbWyaVEwd3YXWPBMGIhqsUppNtzXTmOKN+QspsSV7qb+oO9GhZr8ZHT UaRA/2VKaVD0chQezlTu8khbrdXUIWYKTqDEhA8KQ5EissLIJ/hq1EHgc/DdwnmP4HPx tL12c/3PT6AhIE7/E94jUlKebRGqCGdGzPPWP6hqkOdB6/Ejg1DC6exookga85lbtxus FY/BE6kgR7s9BQolRTvhmdJu0vdVpMtDStM8j00vlBDZstBg2fYIOwitHEVyJ7qx8kLd XUzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-25618-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25618-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n22-20020a170906379600b00a2bb3cc5957si3489367ejc.756.2024.01.14.20.42.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jan 2024 20:42:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25618-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-25618-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25618-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 840471F2115D for ; Mon, 15 Jan 2024 04:42:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 048485C97; Mon, 15 Jan 2024 04:42:11 +0000 (UTC) Received: from mail.nfschina.com (unknown [42.101.60.195]) by smtp.subspace.kernel.org (Postfix) with SMTP id 842AE3D65; Mon, 15 Jan 2024 04:42:04 +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 A054C601ACDBF; Mon, 15 Jan 2024 12:42:01 +0800 (CST) X-MD-Sfrom: kunyu@nfschina.com X-MD-SrcIP: 219.141.250.2 From: Li kunyu To: mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Li kunyu Subject: [PATCH] proc: proc_sysctl: Optimize insert_links() Date: Mon, 15 Jan 2024 12:42:00 +0800 Message-Id: <20240115044200.27922-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: 1788130101099081004 X-GMAIL-MSGID: 1788130101099081004 Optimize the err variable assignment location so that the err variable is manually modified when an error occurs. Signed-off-by: Li kunyu --- fs/proc/proc_sysctl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index cdda684551599..737071754a6e5 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -1258,13 +1258,14 @@ static int insert_links(struct ctl_table_header *head) links = new_links(core_parent, head); spin_lock(&sysctl_lock); - err = -ENOMEM; - if (!links) + if (!links) { + err = -ENOMEM; goto out; + } - err = 0; if (get_links(core_parent, head, head->root)) { kfree(links); + err = 0; goto out; }