* [PATCH] proc: proc_sysctl: Optimize insert_links()
@ 2024-01-15 4:42 Li kunyu
0 siblings, 0 replies; only message in thread
From: Li kunyu @ 2024-01-15 4:42 UTC (permalink / raw)
To: mcgrof, keescook, yzaikin; +Cc: linux-kernel, linux-fsdevel, Li kunyu
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-15 4:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-15 4:42 [PATCH] proc: proc_sysctl: Optimize insert_links() Li kunyu
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).