Skip to content

Commit f8db800

Browse files
maharmstonekdave
authored andcommitted
btrfs: check block group lookup in remove_range_from_remap_tree()
Add a check in remove_range_from_remap_tree() after we call btrfs_lookup_block_group(), to check if it is NULL. This shouldn't happen, but if it does we at least get an error rather than a segfault. Reported-by: Chris Mason <[email protected]> Link: https://lore.kernel.org/linux-btrfs/[email protected]/ Fixes: 979e1dc ("btrfs: handle deletions from remapped block group") Reviewed-by: Filipe Manana <[email protected]> Signed-off-by: Mark Harmstone <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 7885ca4 commit f8db800

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

fs/btrfs/relocation.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5985,6 +5985,9 @@ static int remove_range_from_remap_tree(struct btrfs_trans_handle *trans,
59855985
struct btrfs_block_group *dest_bg;
59865986

59875987
dest_bg = btrfs_lookup_block_group(fs_info, new_addr);
5988+
if (unlikely(!dest_bg))
5989+
return -EUCLEAN;
5990+
59885991
adjust_block_group_remap_bytes(trans, dest_bg, -overlap_length);
59895992
btrfs_put_block_group(dest_bg);
59905993
ret = btrfs_add_to_free_space_tree(trans,

0 commit comments

Comments
 (0)