]> www.infradead.org Git - users/hch/misc.git/commitdiff
btrfs: fix memory leaks when rejecting a non SINGLE data profile without an RST
authorMiquel Sabaté Solà <mssola@mssola.com>
Wed, 8 Oct 2025 12:18:59 +0000 (14:18 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 13 Oct 2025 20:35:14 +0000 (22:35 +0200)
At the end of btrfs_load_block_group_zone_info() the first thing we do
is to ensure that if the mapping type is not a SINGLE one and there is
no RAID stripe tree, then we return early with an error.

Doing that, though, prevents the code from running the last calls from
this function which are about freeing memory allocated during its
run. Hence, in this case, instead of returning early, we set the ret
value and fall through the rest of the cleanup code.

Fixes: 5906333cc4af ("btrfs: zoned: don't skip block group profile checks on conventional zones")
CC: stable@vger.kernel.org # 6.8+
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/zoned.c

index e3341a84f4ab3958d3c0d717c55eac4d6a825cc1..838149fa60ceba31ebebaa9c1bf153c0ebab1854 100644 (file)
@@ -1753,7 +1753,7 @@ out:
            !fs_info->stripe_root) {
                btrfs_err(fs_info, "zoned: data %s needs raid-stripe-tree",
                          btrfs_bg_type_to_raid_name(map->type));
-               return -EINVAL;
+               ret = -EINVAL;
        }
 
        if (unlikely(cache->alloc_offset > cache->zone_capacity)) {