aboutsummaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2011-07-26 19:08:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-26 19:49:44 -0400
commitd40dcdb0172a1ba853464983a059fb45e0aaf61a (patch)
treeaa785c01ad6763c92191b86ec10f526fa772b808 /ipc
parent04715206c0c2fd4ec5ca77fa51e3a5b41ce71492 (diff)
ipc/mqueue.c: fix mq_open() return value
We return ENOMEM from mqueue_get_inode even when we have enough memory. Namely in case the system rlimit of mqueue was reached. This error propagates to mq_queue and user sees the error unexpectedly. So fix this up to properly return EMFILE as described in the manpage: EMFILE The process already has the maximum number of files and message queues open. instead of: ENOMEM Insufficient memory. With the previous patch we just switch to ERR_PTR/PTR_ERR/IS_ERR error handling here. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Manfred Spraul <manfred@colorfullife.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc')
-rw-r--r--ipc/mqueue.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index d43c30f72f1d..ed049ea568f4 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -113,6 +113,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
113{ 113{
114 struct user_struct *u = current_user(); 114 struct user_struct *u = current_user();
115 struct inode *inode; 115 struct inode *inode;
116 int ret = -ENOMEM;
116 117
117 inode = new_inode(sb); 118 inode = new_inode(sb);
118 if (!inode) 119 if (!inode)
@@ -160,6 +161,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
160 u->mq_bytes + mq_bytes > task_rlimit(p, RLIMIT_MSGQUEUE)) { 161 u->mq_bytes + mq_bytes > task_rlimit(p, RLIMIT_MSGQUEUE)) {
161 spin_unlock(&mq_lock); 162 spin_unlock(&mq_lock);
162 /* mqueue_evict_inode() releases info->messages */ 163 /* mqueue_evict_inode() releases info->messages */
164 ret = -EMFILE;
163 goto out_inode; 165 goto out_inode;
164 } 166 }
165 u->mq_bytes += mq_bytes; 167 u->mq_bytes += mq_bytes;
@@ -179,7 +181,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
179out_inode: 181out_inode:
180 iput(inode); 182 iput(inode);
181err: 183err:
182 return NULL; 184 return ERR_PTR(ret);
183} 185}
184 186
185static int mqueue_fill_super(struct super_block *sb, void *data, int silent) 187static int mqueue_fill_super(struct super_block *sb, void *data, int silent)
@@ -195,8 +197,8 @@ static int mqueue_fill_super(struct super_block *sb, void *data, int silent)
195 197
196 inode = mqueue_get_inode(sb, ns, S_IFDIR | S_ISVTX | S_IRWXUGO, 198 inode = mqueue_get_inode(sb, ns, S_IFDIR | S_ISVTX | S_IRWXUGO,
197 NULL); 199 NULL);
198 if (!inode) { 200 if (IS_ERR(inode)) {
199 error = -ENOMEM; 201 error = PTR_ERR(inode);
200 goto out; 202 goto out;
201 } 203 }
202 204
@@ -316,8 +318,8 @@ static int mqueue_create(struct inode *dir, struct dentry *dentry,
316 spin_unlock(&mq_lock); 318 spin_unlock(&mq_lock);
317 319
318 inode = mqueue_get_inode(dir->i_sb, ipc_ns, mode, attr); 320 inode = mqueue_get_inode(dir->i_sb, ipc_ns, mode, attr);
319 if (!inode) { 321 if (IS_ERR(inode)) {
320 error = -ENOMEM; 322 error = PTR_ERR(inode);
321 spin_lock(&mq_lock); 323 spin_lock(&mq_lock);
322 ipc_ns->mq_queues_count--; 324 ipc_ns->mq_queues_count--;
323 goto out_unlock; 325 goto out_unlock;