]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfs: drop the RTG reference later in xfs_ioc_rtgroup_geometry
authorChristoph Hellwig <hch@lst.de>
Wed, 27 May 2026 12:39:28 +0000 (14:39 +0200)
committerCarlos Maiolino <cem@kernel.org>
Sat, 30 May 2026 06:26:18 +0000 (08:26 +0200)
Keep the rtgroup reference until after reporting the write pointer, as
that uses it.  Right now this is not a major issue as we don't support
shrinking file systems in a way that makes RTGs go away, but let's stick
to the proper reference counting to prepare for that.

Fixes: c6ce65cb17aa ("xfs: add write pointer to xfs_rtgroup_geometry")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/xfs_ioctl.c

index 46e234863644f036a40f970b7cfe722bbf0fbf3e..737afcb5652acfb53749dc8d8fe444330b095925 100644 (file)
@@ -433,9 +433,8 @@ xfs_ioc_rtgroup_geometry(
                return -EINVAL;
 
        error = xfs_rtgroup_get_geometry(rtg, &rgeo);
-       xfs_rtgroup_put(rtg);
        if (error)
-               return error;
+               goto out_put_rtg;
 
        if (xfs_has_zoned(mp)) {
                xfs_rtgroup_lock(rtg, XFS_RTGLOCK_RMAP);
@@ -453,8 +452,10 @@ xfs_ioc_rtgroup_geometry(
        }
 
        if (copy_to_user(arg, &rgeo, sizeof(rgeo)))
-               return -EFAULT;
-       return 0;
+               error = -EFAULT;
+out_put_rtg:
+       xfs_rtgroup_put(rtg);
+       return error;
 }
 
 /*