Commit 4e7de35e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba
Browse files

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: 03793cbb ("btrfs: add fast path for single device io in __btrfs_map_block")
Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent b19c98f2
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -6398,6 +6398,7 @@ 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);
		if (mirror_num_ret)
			*mirror_num_ret = mirror_num;
		*bioc_ret = NULL;
		ret = 0;