]> 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:37:38 +0000 (14:37 +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 38c5be34c8951f3589b1ee64193085e027c22392..8acefe5f654c9eef5c2499b9313d0ae6ec42c310 100644 (file)
@@ -191,8 +191,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;