gfs2: gfs2_create_inode error handling fix
authorAndreas Gruenbacher <agruenba@redhat.com>
Fri, 18 Apr 2025 14:40:58 +0000 (16:40 +0200)
committerAndreas Gruenbacher <agruenba@redhat.com>
Mon, 21 Apr 2025 16:20:36 +0000 (18:20 +0200)
When gfs2_create_inode() finds a directory, make sure to return -EISDIR.

Fixes: 571a4b57975a ("GFS2: bugger off early if O_CREAT open finds a directory")
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/inode.c

index 198a8cbaf5e5ad489a8dfc0494cbc6ff56b855cb..9621680814b8050625b255c9c1447f80f27a081c 100644 (file)
@@ -659,7 +659,8 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
        if (!IS_ERR(inode)) {
                if (S_ISDIR(inode->i_mode)) {
                        iput(inode);
-                       inode = ERR_PTR(-EISDIR);
+                       inode = NULL;
+                       error = -EISDIR;
                        goto fail_gunlock;
                }
                d_instantiate(dentry, inode);