gfs2: bugger off early if O_CREAT open finds a directory
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 18 Sep 2014 21:38:59 +0000 (17:38 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 19 Nov 2014 17:57:14 +0000 (12:57 -0500)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/gfs2/inode.c

index c4ed823d150e9609529ef1789874801180bcd4d9..310e2487239da4572927415f318c98a664e76d00 100644 (file)
@@ -624,6 +624,11 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
        inode = gfs2_dir_search(dir, &dentry->d_name, !S_ISREG(mode) || excl);
        error = PTR_ERR(inode);
        if (!IS_ERR(inode)) {
+               if (S_ISDIR(inode->i_mode)) {
+                       iput(inode);
+                       inode = ERR_PTR(-EISDIR);
+                       goto fail_gunlock;
+               }
                d = d_splice_alias(inode, dentry);
                error = PTR_ERR(d);
                if (IS_ERR(d)) {