{
        struct user_struct *u = current_user();
        struct inode *inode;
+       int ret = -ENOMEM;
 
        inode = new_inode(sb);
        if (!inode)
                    u->mq_bytes + mq_bytes > task_rlimit(p, RLIMIT_MSGQUEUE)) {
                        spin_unlock(&mq_lock);
                        /* mqueue_evict_inode() releases info->messages */
+                       ret = -EMFILE;
                        goto out_inode;
                }
                u->mq_bytes += mq_bytes;
 out_inode:
        iput(inode);
 err:
-       return NULL;
+       return ERR_PTR(ret);
 }
 
 static int mqueue_fill_super(struct super_block *sb, void *data, int silent)
 
        inode = mqueue_get_inode(sb, ns, S_IFDIR | S_ISVTX | S_IRWXUGO,
                                NULL);
-       if (!inode) {
-               error = -ENOMEM;
+       if (IS_ERR(inode)) {
+               error = PTR_ERR(inode);
                goto out;
        }
 
        spin_unlock(&mq_lock);
 
        inode = mqueue_get_inode(dir->i_sb, ipc_ns, mode, attr);
-       if (!inode) {
-               error = -ENOMEM;
+       if (IS_ERR(inode)) {
+               error = PTR_ERR(inode);
                spin_lock(&mq_lock);
                ipc_ns->mq_queues_count--;
                goto out_unlock;