]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
btrfs: fix chunk map leak in btrfs_map_block() after btrfs_chunk_map_num_copies()
authorMark Harmstone <mark@harmstone.com>
Fri, 20 Feb 2026 12:53:17 +0000 (12:53 +0000)
committerDavid Sterba <dsterba@suse.com>
Thu, 26 Feb 2026 14:03:29 +0000 (15:03 +0100)
Fix a chunk map leak in btrfs_map_block(): if we return early with -EINVAL,
we're not freeing the chunk map that we've just looked up.

Fixes: 0ae653fbec2b ("btrfs: reduce chunk_map lookups in btrfs_map_block()")
CC: stable@vger.kernel.org # 6.12+
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Mark Harmstone <mark@harmstone.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c

index 50f7aae70418f8509094ebe414773126e36a1fdf..b8cbd3ecb94d34cfebf487adf173ddfa9b4224f0 100644 (file)
@@ -6921,8 +6921,10 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
        }
 
        num_copies = btrfs_chunk_map_num_copies(map);
-       if (io_geom.mirror_num > num_copies)
-               return -EINVAL;
+       if (io_geom.mirror_num > num_copies) {
+               ret = -EINVAL;
+               goto out;
+       }
 
        map_offset = logical - map->start;
        io_geom.raid56_full_stripe_start = (u64)-1;