Commit 04715206 authored by Jiri Slaby's avatar Jiri Slaby Committed by Linus Torvalds

ipc/mqueue.c: refactor failure handling

If new_inode fails to allocate an inode we need only to return with
NULL.  But now we test the opposite and have all the work in a nested
block.  So do the opposite to save one indentation level (and remove
unnecessary line breaks).

This is only a preparation/cleanup for the next patch where we fix up
return values from mqueue_get_inode.
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Cc: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a64a26e8
...@@ -115,13 +115,14 @@ static struct inode *mqueue_get_inode(struct super_block *sb, ...@@ -115,13 +115,14 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
struct inode *inode; struct inode *inode;
inode = new_inode(sb); inode = new_inode(sb);
if (inode) { if (!inode)
goto err;
inode->i_ino = get_next_ino(); inode->i_ino = get_next_ino();
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = current_fsuid(); inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid(); inode->i_gid = current_fsgid();
inode->i_mtime = inode->i_ctime = inode->i_atime = inode->i_mtime = inode->i_ctime = inode->i_atime = CURRENT_TIME;
CURRENT_TIME;
if (S_ISREG(mode)) { if (S_ISREG(mode)) {
struct mqueue_inode_info *info; struct mqueue_inode_info *info;
...@@ -156,8 +157,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb, ...@@ -156,8 +157,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
spin_lock(&mq_lock); spin_lock(&mq_lock);
if (u->mq_bytes + mq_bytes < u->mq_bytes || if (u->mq_bytes + mq_bytes < u->mq_bytes ||
u->mq_bytes + mq_bytes > u->mq_bytes + mq_bytes > task_rlimit(p, RLIMIT_MSGQUEUE)) {
task_rlimit(p, RLIMIT_MSGQUEUE)) {
spin_unlock(&mq_lock); spin_unlock(&mq_lock);
/* mqueue_evict_inode() releases info->messages */ /* mqueue_evict_inode() releases info->messages */
goto out_inode; goto out_inode;
...@@ -174,10 +174,11 @@ static struct inode *mqueue_get_inode(struct super_block *sb, ...@@ -174,10 +174,11 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
inode->i_op = &mqueue_dir_inode_operations; inode->i_op = &mqueue_dir_inode_operations;
inode->i_fop = &simple_dir_operations; inode->i_fop = &simple_dir_operations;
} }
}
return inode; return inode;
out_inode: out_inode:
iput(inode); iput(inode);
err:
return NULL; return NULL;
} }
......
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