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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1211148109-16149-1-git-send-email-marcin.slusarz@gmail.com>
Date:	Mon, 19 May 2008 00:01:49 +0200
From:	Marcin Slusarz <marcin.slusarz@...il.com>
To:	LKML <linux-kernel@...r.kernel.org>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Al Viro <viro@...IV.linux.org.uk>,
	Christoph Hellwig <hch@....de>
Subject: [PATCH 3/6] vfs: open_exec cleanup

open_exec is needlessly indented, calls ERR_PTR with 0 argument
(which is not valid errno) and jumps into middle of function
just to return value.
So clean it up a bit.

Signed-off-by: Marcin Slusarz <marcin.slusarz@...il.com>
Cc: Al Viro <viro@...iv.linux.org.uk>
Cc: Andrew Morton <akpm@...ux-foundation.org>
---
 fs/exec.c |   44 ++++++++++++++++++++++----------------------
 1 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index aeaa979..ca8b512 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -656,34 +656,34 @@ struct file *open_exec(const char *name)
 	struct nameidata nd;
 	int err;
 	struct file *file;
+	struct inode *inode;
 
 	err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd, FMODE_READ|FMODE_EXEC);
-	file = ERR_PTR(err);
-
-	if (!err) {
-		struct inode *inode = nd.path.dentry->d_inode;
-		file = ERR_PTR(-EACCES);
-		if (S_ISREG(inode->i_mode)) {
-			int err = vfs_permission(&nd, MAY_EXEC);
-			file = ERR_PTR(err);
-			if (!err) {
-				file = nameidata_to_filp(&nd,
-							O_RDONLY|O_LARGEFILE);
-				if (!IS_ERR(file)) {
-					err = deny_write_access(file);
-					if (err) {
-						fput(file);
-						file = ERR_PTR(err);
-					}
+	if (err)
+		return ERR_PTR(err);
+
+	inode = nd.path.dentry->d_inode;
+	file = ERR_PTR(-EACCES);
+	if (S_ISREG(inode->i_mode)) {
+		int err = vfs_permission(&nd, MAY_EXEC);
+		if (!err) {
+			file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE);
+			if (!IS_ERR(file)) {
+				err = deny_write_access(file);
+				if (err) {
+					fput(file);
+					file = ERR_PTR(err);
 				}
-out:
-				return file;
 			}
+			goto out;
 		}
-		release_open_intent(&nd);
-		path_put(&nd.path);
+		else
+			file = ERR_PTR(err);
 	}
-	goto out;
+	release_open_intent(&nd);
+	path_put(&nd.path);
+out:
+	return file;
 }
 
 EXPORT_SYMBOL(open_exec);
-- 
1.5.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ