[PATCH] Code style fix for open_exec

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From d2a6c5d29dc34cfea892124ab72b4eb55d2f8a80 Mon Sep 17 00:00:00 2001
From: Casey Dahlin <[email protected]>
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 <[email protected]>

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);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux