summaryrefslogtreecommitdiffstats
path: root/fs/jffs2/fs.c
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2010-06-03 09:09:12 +0200
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-06-03 09:22:04 +0200
commite72e6497e74811e01d72b4c1b7537b3aea3ee857 (patch)
treed78dec67d0aaeea807e5ab32141802620ec7ae41 /fs/jffs2/fs.c
parentjffs2: Fix in-core inode leaks on error paths (diff)
downloadlinux-e72e6497e74811e01d72b4c1b7537b3aea3ee857.tar.xz
linux-e72e6497e74811e01d72b4c1b7537b3aea3ee857.zip
jffs2: Fix NFS race by using insert_inode_locked()
New inodes need to be locked as we're creating them, so they don't get used by other things (like NFSd) before they're ready. Pointed out by Al Viro. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'fs/jffs2/fs.c')
-rw-r--r--fs/jffs2/fs.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 86e0821fc989..26037e2d6154 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -465,7 +465,12 @@ struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_i
inode->i_blocks = 0;
inode->i_size = 0;
- insert_inode_hash(inode);
+ if (insert_inode_locked(inode) < 0) {
+ make_bad_inode(inode);
+ unlock_new_inode(inode);
+ iput(inode);
+ return ERR_PTR(-EINVAL);
+ }
return inode;
}