• Qu Wenruo's avatar
    btrfs: reset destination buffer when read_extent_buffer() gets invalid range · 74ee7914
    Qu Wenruo authored
    Commit f98b6215 ("btrfs: extent_io: do extra check for extent buffer
    read write functions") changed how we handle invalid extent buffer range
    for read_extent_buffer().
    
    Previously if the range is invalid we just set the destination to zero,
    but after the patch we do nothing and error out.
    
    This can lead to smatch static checker errors like:
    
      fs/btrfs/print-tree.c:186 print_uuid_item() error: uninitialized symbol 'subvol_id'.
      fs/btrfs/tests/extent-io-tests.c:338 check_eb_bitmap() error: uninitialized symbol 'has'.
      fs/btrfs/tests/extent-io-tests.c:353 check_eb_bitmap() error: uninitialized symbol 'has'.
      fs/btrfs/uuid-tree.c:203 btrfs_uuid_tree_remove() error: uninitialized symbol 'read_subid'.
      fs/btrfs/uuid-tree.c:353 btrfs_uuid_tree_iterate() error: uninitialized symbol 'subid_le'.
      fs/btrfs/uuid-tree.c:72 btrfs_uuid_tree_lookup() error: uninitialized symbol 'data'.
      fs/btrfs/volumes.c:7415 btrfs_dev_stats_value() error: uninitialized symbol 'val'.
    
    Fix those warnings by reverting back to the old memset() behavior.
    By this we keep the static checker happy and would still make a lot of
    noise when such invalid ranges are passed in.
    Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
    Fixes: f98b6215 ("btrfs: extent_io: do extra check for extent buffer read write functions")
    Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    74ee7914
extent_io.c 128 KB