summaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorAndré Goddard Rosa <andre.goddard@gmail.com>2010-02-23 04:04:25 -0300
committerAl Viro <viro@zeniv.linux.org.uk>2010-03-03 14:48:00 -0500
commit04db0dde0ee1c29110642dff57fba9e438eb805c (patch)
treeca80ec3e48470f70d233fcabf4c8d79c4b3c4bc7 /ipc
parent8834cf796a4320be2d3a70b1e4f9aba732a0f4ee (diff)
downloadlinux-04db0dde0ee1c29110642dff57fba9e438eb805c.tar.gz
linux-04db0dde0ee1c29110642dff57fba9e438eb805c.tar.bz2
linux-04db0dde0ee1c29110642dff57fba9e438eb805c.zip
mqueue: simplify do_open() error handling
It reduces code size: text data bss dec hex filename 9925 72 16 10013 271d ipc/mqueue-BEFORE.o 9885 72 16 9973 26f5 ipc/mqueue-AFTER.o Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'ipc')
-rw-r--r--ipc/mqueue.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 15eabf9d51fd..3853116a2ef8 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -657,24 +657,28 @@ out:
static struct file *do_open(struct ipc_namespace *ipc_ns,
struct dentry *dentry, int oflag)
{
+ int ret;
const struct cred *cred = current_cred();
static const int oflag2acc[O_ACCMODE] = { MAY_READ, MAY_WRITE,
MAY_READ | MAY_WRITE };
if ((oflag & O_ACCMODE) == (O_RDWR | O_WRONLY)) {
- dput(dentry);
- mntput(ipc_ns->mq_mnt);
- return ERR_PTR(-EINVAL);
+ ret = -EINVAL;
+ goto err;
}
if (inode_permission(dentry->d_inode, oflag2acc[oflag & O_ACCMODE])) {
- dput(dentry);
- mntput(ipc_ns->mq_mnt);
- return ERR_PTR(-EACCES);
+ ret = -EACCES;
+ goto err;
}
return dentry_open(dentry, ipc_ns->mq_mnt, oflag, cred);
+
+err:
+ dput(dentry);
+ mntput(ipc_ns->mq_mnt);
+ return ERR_PTR(ret);
}
SYSCALL_DEFINE4(mq_open, const char __user *, u_name, int, oflag, mode_t, mode,