btrfs: be a bit more careful when setting mirror_num_ret in btrfs_map_block
authorChristoph Hellwig <hch@lst.de>
Tue, 27 Jun 2023 06:13:23 +0000 (08:13 +0200)
committerDavid Sterba <dsterba@suse.com>
Tue, 11 Jul 2023 15:32:14 +0000 (17:32 +0200)
commit4e7de35eb7d1a1d4f2dda15f39fbedd4798a0b8d
tree90b5b60c7393edb761abaf278129b83373176252
parentb19c98f237cd76981aaded52c258ce93f7daa8cb
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: 03793cbbc80f ("btrfs: add fast path for single device io in __btrfs_map_block")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c