]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
xfs: fix xfs_ifree() error handling to not leak perag ref
authorBrian Foster <bfoster@redhat.com>
Thu, 22 Sep 2022 15:15:00 +0000 (08:15 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 23 Nov 2022 14:11:40 +0000 (15:11 +0100)
BugLink: https://bugs.launchpad.net/bugs/1995420
[ Upstream commit 6f5097e3367a7c0751e165e4c15bc30511a4ba38 ]

For some reason commit 9a5280b312e2e ("xfs: reorder iunlink remove
operation in xfs_ifree") replaced a jump to the exit path in the
event of an xfs_difree() error with a direct return, which skips
releasing the perag reference acquired at the top of the function.
Restore the original code to drop the reference on error.

Fixes: 9a5280b312e2e ("xfs: reorder iunlink remove operation in xfs_ifree")
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Leah Rumancik <leah.rumancik@gmail.com>
Acked-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/xfs/xfs_inode.c

index 36bcdcf3bb78c7395b2aedb9f329048bfb241d92..b2ea853182141c028840587e11ca07aa3e7ada15 100644 (file)
@@ -2634,7 +2634,7 @@ xfs_ifree(
         */
        error = xfs_difree(tp, pag, ip->i_ino, &xic);
        if (error)
-               return error;
+               goto out;
 
        error = xfs_iunlink_remove(tp, pag, ip);
        if (error)