]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
spufs: fix a leak on spufs_new_file() failure
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 9 Mar 2025 00:26:31 +0000 (19:26 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Apr 2025 12:31:00 +0000 (14:31 +0200)
[ Upstream commit d1ca8698ca1332625d83ea0d753747be66f9906d ]

It's called from spufs_fill_dir(), and caller of that will do
spufs_rmdir() in case of failure.  That does remove everything
we'd managed to create, but... the problem dentry is still
negative.  IOW, it needs to be explicitly dropped.

Fixes: 3f51dd91c807 "[PATCH] spufs: fix spufs_fill_dir error path"
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/powerpc/platforms/cell/spufs/inode.c

index 908e9b8e79fe630da0a216c3696fd782aa130741..0159bd9231ef804e91bb34f9da4044db61a633dd 100644 (file)
@@ -189,8 +189,10 @@ static int spufs_fill_dir(struct dentry *dir,
                        return -ENOMEM;
                ret = spufs_new_file(dir->d_sb, dentry, files->ops,
                                        files->mode & mode, files->size, ctx);
-               if (ret)
+               if (ret) {
+                       dput(dentry);
                        return ret;
+               }
                files++;
        }
        return 0;