From: Li kunyu <kunyu@nfschina.com>
To: mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Li kunyu <kunyu@nfschina.com>
Subject: [PATCH] proc: proc_sysctl: Optimize insert_links()
Date: Mon, 15 Jan 2024 12:42:00 +0800 [thread overview]
Message-ID: <20240115044200.27922-1-kunyu@nfschina.com> (raw)
Optimize the err variable assignment location so that the err variable
is manually modified when an error occurs.
Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
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;
}
--
2.18.2
reply other threads:[~2024-01-15 4:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240115044200.27922-1-kunyu@nfschina.com \
--to=kunyu@nfschina.com \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=yzaikin@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).