mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 03:04:51 +01:00
btrfs: remove bogus NULL checks in __btrfs_write_out_cache()
Dan reported a new smatch warning in free-space-cache.c: New smatch warnings: fs/btrfs/free-space-cache.c:1207 write_pinned_extent_entries() warn: variable dereferenced before check 'block_group' (see line 1203) But the check if the block_group pointer is NULL is bogus, because to get to this point block_group::io_ctl has already been dereferenced further up the call-chain when calling __btrfs_write_out_cache() from btrfs_write_out_cache(). Remove the bogus checks for block_group == NULL in __btrfs_write_out_cache() and it's siblings. Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/r/202601170636.WsePMV5H-lkp@intel.com/ Reviewed-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
2aef934b56
commit
57a4a863cd
1 changed files with 4 additions and 7 deletions
|
|
@ -1080,7 +1080,7 @@ int write_cache_extent_entries(struct btrfs_io_ctl *io_ctl,
|
|||
struct btrfs_trim_range *trim_entry;
|
||||
|
||||
/* Get the cluster for this block_group if it exists */
|
||||
if (block_group && !list_empty(&block_group->cluster_list)) {
|
||||
if (!list_empty(&block_group->cluster_list)) {
|
||||
cluster = list_first_entry(&block_group->cluster_list,
|
||||
struct btrfs_free_cluster, block_group_list);
|
||||
}
|
||||
|
|
@ -1204,9 +1204,6 @@ static noinline_for_stack int write_pinned_extent_entries(
|
|||
struct extent_io_tree *unpin = NULL;
|
||||
int ret;
|
||||
|
||||
if (!block_group)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* We want to add any pinned extents to our free space cache
|
||||
* so we don't leak the space
|
||||
|
|
@ -1394,7 +1391,7 @@ static int __btrfs_write_out_cache(struct inode *inode,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (block_group && (block_group->flags & BTRFS_BLOCK_GROUP_DATA)) {
|
||||
if (block_group->flags & BTRFS_BLOCK_GROUP_DATA) {
|
||||
down_write(&block_group->data_rwsem);
|
||||
spin_lock(&block_group->lock);
|
||||
if (block_group->delalloc_bytes) {
|
||||
|
|
@ -1466,7 +1463,7 @@ static int __btrfs_write_out_cache(struct inode *inode,
|
|||
goto out_nospc;
|
||||
}
|
||||
|
||||
if (block_group && (block_group->flags & BTRFS_BLOCK_GROUP_DATA))
|
||||
if (block_group->flags & BTRFS_BLOCK_GROUP_DATA)
|
||||
up_write(&block_group->data_rwsem);
|
||||
/*
|
||||
* Release the pages and unlock the extent, we will flush
|
||||
|
|
@ -1501,7 +1498,7 @@ out_nospc:
|
|||
cleanup_write_cache_enospc(inode, io_ctl, &cached_state);
|
||||
|
||||
out_unlock:
|
||||
if (block_group && (block_group->flags & BTRFS_BLOCK_GROUP_DATA))
|
||||
if (block_group->flags & BTRFS_BLOCK_GROUP_DATA)
|
||||
up_write(&block_group->data_rwsem);
|
||||
|
||||
out:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue