Skip to content

Commit 4e7de35

Browse files
Christoph Hellwigkdave
authored andcommitted
btrfs: be a bit more careful when setting mirror_num_ret in btrfs_map_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]>
1 parent b19c98f commit 4e7de35

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/btrfs/volumes.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6398,7 +6398,8 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
63986398
(op == BTRFS_MAP_READ || !dev_replace_is_ongoing ||
63996399
!dev_replace->tgtdev)) {
64006400
set_io_stripe(smap, map, stripe_index, stripe_offset, stripe_nr);
6401-
*mirror_num_ret = mirror_num;
6401+
if (mirror_num_ret)
6402+
*mirror_num_ret = mirror_num;
64026403
*bioc_ret = NULL;
64036404
ret = 0;
64046405
goto out;

0 commit comments

Comments
 (0)