]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
spufs: fix a leak in spufs_create_context()
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 12 Mar 2025 23:38:28 +0000 (19:38 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Apr 2025 12:31:00 +0000 (14:31 +0200)
[ Upstream commit 0f5cce3fc55b08ee4da3372baccf4bcd36a98396 ]

Leak fixes back in 2008 missed one case - if we are trying to set affinity
and spufs_mkdir() fails, we need to drop the reference to neighbor.

Fixes: 58119068cb27 "[POWERPC] spufs: Fix memory leak on SPU affinity"
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 0159bd9231ef804e91bb34f9da4044db61a633dd..373814bbc43d7e840d28623293460d9e896454a4 100644 (file)
@@ -438,8 +438,11 @@ spufs_create_context(struct inode *inode, struct dentry *dentry,
        }
 
        ret = spufs_mkdir(inode, dentry, flags, mode & 0777);
-       if (ret)
+       if (ret) {
+               if (neighbor)
+                       put_spu_context(neighbor);
                goto out_aff_unlock;
+       }
 
        if (affinity) {
                spufs_set_affinity(flags, SPUFS_I(d_inode(dentry))->i_ctx,