public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Casey Dahlin <cjdahlin@ncsu.edu>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] Code style fix for open_exec
Date: Wed, 03 Oct 2007 22:40:25 -0400	[thread overview]
Message-ID: <47045299.2000601@ncsu.edu> (raw)

 From d2a6c5d29dc34cfea892124ab72b4eb55d2f8a80 Mon Sep 17 00:00:00 2001
From: Casey Dahlin <cjdahlin@ncsu.edu>
Date: Wed, 3 Oct 2007 22:01:49 -0400
Subject: [PATCH] Code style fix for open_exec

Fix a horribly mangled 5 level indent and severe abuse of goto in the 
open_exec
function.

Signed-off-by: Casey Dahlin <cjdahlin@ncsu.edu>

diff --git a/fs/exec.c b/fs/exec.c
index c21a8cc..d73da5a 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -676,32 +676,32 @@ struct file *open_exec(const char *name)
     struct file *file;
 
     err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd, 
FMODE_READ|FMODE_EXEC);
+
+    if (err) return ERR_PTR(err);
+
+    file = ERR_PTR(-EACCES);
+    if ((nd.mnt->mnt_flags & MNT_NOEXEC) ||
+            !S_ISREG(nd.dentry->d_inode->i_mode))
+        goto fail;
+
+    err = vfs_permission(&nd, MAY_EXEC);
     file = ERR_PTR(err);
+    if (err) goto fail;
 
-    if (!err) {
-        struct inode *inode = nd.dentry->d_inode;
-        file = ERR_PTR(-EACCES);
-        if (!(nd.mnt->mnt_flags & MNT_NOEXEC) &&
-            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);
-                if (!IS_ERR(file)) {
-                    err = deny_write_access(file);
-                    if (err) {
-                        fput(file);
-                        file = ERR_PTR(err);
-                    }
-                }
-out:
-                return file;
-            }
-        }
-        release_open_intent(&nd);
-        path_release(&nd);
+    file = nameidata_to_filp(&nd, O_RDONLY);
+    if (IS_ERR(file)) return file;
+
+    err = deny_write_access(file);
+    if (err) {
+        fput(file);
+        file = ERR_PTR(err);
     }
-    goto out;
+
+    return file;
+fail:
+    release_open_intent(&nd);
+    path_release(&nd);
+    return file;
 }
 
 EXPORT_SYMBOL(open_exec);

             reply	other threads:[~2007-10-04  2:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-04  2:40 Casey Dahlin [this message]
2007-10-04  7:08 ` [PATCH] Code style fix for open_exec Christoph Hellwig
2007-10-04 17:35   ` Casey Dahlin

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=47045299.2000601@ncsu.edu \
    --to=cjdahlin@ncsu.edu \
    --cc=linux-kernel@vger.kernel.org \
    /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