lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240115044200.27922-1-kunyu@nfschina.com>
Date: Mon, 15 Jan 2024 12:42:00 +0800
From: Li kunyu <kunyu@...china.com>
To: mcgrof@...nel.org,
	keescook@...omium.org,
	yzaikin@...gle.com
Cc: linux-kernel@...r.kernel.org,
	linux-fsdevel@...r.kernel.org,
	Li kunyu <kunyu@...china.com>
Subject: [PATCH] proc: proc_sysctl: Optimize insert_links()

Optimize the err variable assignment location so that the err variable
is manually modified when an error occurs.

Signed-off-by: Li kunyu <kunyu@...china.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ