Skip to content

Commit f15fb3d

Browse files
maharmstonekdave
authored andcommitted
btrfs: fix chunk map leak in btrfs_map_block() after btrfs_chunk_map_num_copies()
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: 0ae653f ("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>
1 parent 587bb33 commit f15fb3d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

fs/btrfs/volumes.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6921,8 +6921,10 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
69216921
}
69226922

69236923
num_copies = btrfs_chunk_map_num_copies(map);
6924-
if (io_geom.mirror_num > num_copies)
6925-
return -EINVAL;
6924+
if (io_geom.mirror_num > num_copies) {
6925+
ret = -EINVAL;
6926+
goto out;
6927+
}
69266928

69276929
map_offset = logical - map->start;
69286930
io_geom.raid56_full_stripe_start = (u64)-1;

0 commit comments

Comments
 (0)