Skip to content

Commit 571a4b5

Browse files
Al Viroswhiteho
authored andcommitted
GFS2: bugger off early if O_CREAT open finds a directory
Signed-off-by: Al Viro <[email protected]> Signed-off-by: Steven Whitehouse <[email protected]>
1 parent 30badc9 commit 571a4b5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/gfs2/inode.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,11 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
624624
inode = gfs2_dir_search(dir, &dentry->d_name, !S_ISREG(mode) || excl);
625625
error = PTR_ERR(inode);
626626
if (!IS_ERR(inode)) {
627+
if (S_ISDIR(inode->i_mode)) {
628+
iput(inode);
629+
inode = ERR_PTR(-EISDIR);
630+
goto fail_gunlock;
631+
}
627632
d = d_splice_alias(inode, dentry);
628633
error = PTR_ERR(d);
629634
if (IS_ERR(d)) {

0 commit comments

Comments
 (0)