* [bug report] btrfs: get fs_info from block group in write_pinned_extent_entries
@ 2019-04-24 9:52 Dan Carpenter
2019-04-24 13:41 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2019-04-24 9:52 UTC (permalink / raw)
To: dsterba; +Cc: linux-btrfs
Hello David Sterba,
This is a semi-automatic email about new static checker warnings.
The patch b4c7c5d50791: "btrfs: get fs_info from block group in
write_pinned_extent_entries" from Mar 20, 2019, leads to the
following Smatch complaint:
fs/btrfs/free-space-cache.c:1052 write_pinned_extent_entries()
warn: variable dereferenced before check 'block_group' (see line 1047)
fs/btrfs/free-space-cache.c
1046 {
1047 struct btrfs_fs_info *fs_info = block_group->fs_info;
^^^^^^^^^^^^^^^^^^^^
The patch adds a dereference
1048 u64 start, extent_start, extent_end, len;
1049 struct extent_io_tree *unpin = NULL;
1050 int ret;
1051
1052 if (!block_group)
^^^^^^^^^^^
But the old code assumed it could be NULL.
1053 return 0;
1054
See also:
fs/btrfs/free-space-cache.c:1319 __btrfs_write_out_cache() warn: variable dereferenced before check 'block_group' (see line 1295)
fs/btrfs/free-space-cache.c:1295 __btrfs_write_out_cache() error: we previously assumed 'block_group' could be null (see line 1253)
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] btrfs: get fs_info from block group in write_pinned_extent_entries
2019-04-24 9:52 [bug report] btrfs: get fs_info from block group in write_pinned_extent_entries Dan Carpenter
@ 2019-04-24 13:41 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2019-04-24 13:41 UTC (permalink / raw)
To: Dan Carpenter; +Cc: dsterba, linux-btrfs
On Wed, Apr 24, 2019 at 12:52:54PM +0300, Dan Carpenter wrote:
> Hello David Sterba,
>
> This is a semi-automatic email about new static checker warnings.
>
> The patch b4c7c5d50791: "btrfs: get fs_info from block group in
> write_pinned_extent_entries" from Mar 20, 2019, leads to the
> following Smatch complaint:
>
> fs/btrfs/free-space-cache.c:1052 write_pinned_extent_entries()
> warn: variable dereferenced before check 'block_group' (see line 1047)
>
> fs/btrfs/free-space-cache.c
> 1046 {
> 1047 struct btrfs_fs_info *fs_info = block_group->fs_info;
> ^^^^^^^^^^^^^^^^^^^^
> The patch adds a dereference
>
> 1048 u64 start, extent_start, extent_end, len;
> 1049 struct extent_io_tree *unpin = NULL;
> 1050 int ret;
> 1051
> 1052 if (!block_group)
> ^^^^^^^^^^^
> But the old code assumed it could be NULL.
Thanks for the report. The pointer will never be null as the caller will
pass a valid pointer, so the dereference is ok. This extra check is
redundant so I'll remove it.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-24 13:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 9:52 [bug report] btrfs: get fs_info from block group in write_pinned_extent_entries Dan Carpenter
2019-04-24 13:41 ` David Sterba
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.