Commit e56b6a5d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Al Viro

Re: [PATCH 3/6] vfs: open_exec cleanup

On Mon, May 19, 2008 at 12:01:49AM +0200, Marcin Slusarz wrote:
> 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.

Still looks rather messy.  See below for a better version.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent beb29e05
...@@ -656,38 +656,40 @@ EXPORT_SYMBOL(setup_arg_pages); ...@@ -656,38 +656,40 @@ EXPORT_SYMBOL(setup_arg_pages);
struct file *open_exec(const char *name) struct file *open_exec(const char *name)
{ {
struct nameidata nd; struct nameidata nd;
int err;
struct file *file; struct file *file;
int err;
err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd, FMODE_READ|FMODE_EXEC); err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd,
file = ERR_PTR(err); FMODE_READ|FMODE_EXEC);
if (err)
if (!err) { goto out;
struct inode *inode = nd.path.dentry->d_inode;
file = ERR_PTR(-EACCES); err = -EACCES;
if (S_ISREG(inode->i_mode)) { if (!S_ISREG(nd.path.dentry->d_inode->i_mode))
int err = vfs_permission(&nd, MAY_EXEC | MAY_OPEN); goto out_path_put;
file = ERR_PTR(err);
if (!err) { err = vfs_permission(&nd, MAY_EXEC | MAY_OPEN);
file = nameidata_to_filp(&nd, if (err)
O_RDONLY|O_LARGEFILE); goto out_path_put;
if (!IS_ERR(file)) {
err = deny_write_access(file); file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE);
if (err) { if (IS_ERR(file))
fput(file); return file;
file = ERR_PTR(err);
} err = deny_write_access(file);
} if (err) {
out: fput(file);
return file; goto out;
}
}
release_open_intent(&nd);
path_put(&nd.path);
} }
goto out;
}
return file;
out_path_put:
release_open_intent(&nd);
path_put(&nd.path);
out:
return ERR_PTR(err);
}
EXPORT_SYMBOL(open_exec); EXPORT_SYMBOL(open_exec);
int kernel_read(struct file *file, unsigned long offset, int kernel_read(struct file *file, unsigned long offset,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment