Skip to content

Commit

Permalink
btrfs: be a bit more careful when setting mirror_num_ret in btrfs_map…
Browse files Browse the repository at this point in the history
…_block

The mirror_num_ret is allowed to be NULL, although it has to be set when
smap is set.  Unfortunately that is not a well enough specifiable
invariant for static type checkers, so add a NULL check to make sure they
are fine.

Fixes: 03793cb ("btrfs: add fast path for single device io in __btrfs_map_block")
Reported-by: Dan Carpenter <[email protected]>
Reviewed-by: Qu Wenruo <[email protected]>
Reviewed-by: Johannes Thumshirn <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
Christoph Hellwig authored and kdave committed Jul 11, 2023
1 parent b19c98f commit 4e7de35
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -6398,7 +6398,8 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
(op == BTRFS_MAP_READ || !dev_replace_is_ongoing ||
!dev_replace->tgtdev)) {
set_io_stripe(smap, map, stripe_index, stripe_offset, stripe_nr);
*mirror_num_ret = mirror_num;
if (mirror_num_ret)
*mirror_num_ret = mirror_num;
*bioc_ret = NULL;
ret = 0;
goto out;
Expand Down

0 comments on commit 4e7de35

Please sign in to comment.