Message ID | 9e430348860c37c68f7db326df933c0d3ae8bcc0.1730898720.git.fdmanana@suse.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | btrfs: remove check for NULL fs_info at btrfs_folio_end_lock_bitmap() | expand |
On Wed, Nov 06, 2024 at 01:13:53PM +0000, fdmanana@kernel.org wrote: > From: Filipe Manana <fdmanana@suse.com> > > Smatch complains about possibly dereferecing a NULL fs_info at > btrfs_folio_end_lock_bitmap(): > > fs/btrfs/subpage.c:332 btrfs_folio_end_lock_bitmap() warn: variable dereferenced before check 'fs_info' (see line 326) > > because we access fs_info to set the 'start_bit' variable before doing the > check for a NULL fs_info. > > However fs_info is never NULL, since in the only caller of > btrfs_folio_end_lock_bitmap() is extent_writepage(), where we have an > inode which always as a non-NULL fs_info. > > So remove the check for a NULL fs_info at btrfs_folio_end_lock_bitmap(). > > Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com>
在 2024/11/6 23:43, fdmanana@kernel.org 写道: > From: Filipe Manana <fdmanana@suse.com> > > Smatch complains about possibly dereferecing a NULL fs_info at > btrfs_folio_end_lock_bitmap(): > > fs/btrfs/subpage.c:332 btrfs_folio_end_lock_bitmap() warn: variable dereferenced before check 'fs_info' (see line 326) > > because we access fs_info to set the 'start_bit' variable before doing the > check for a NULL fs_info. > > However fs_info is never NULL, since in the only caller of > btrfs_folio_end_lock_bitmap() is extent_writepage(), where we have an > inode which always as a non-NULL fs_info. > > So remove the check for a NULL fs_info at btrfs_folio_end_lock_bitmap(). > > Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Thanks, Qu > --- > fs/btrfs/subpage.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/btrfs/subpage.c b/fs/btrfs/subpage.c > index d4cab3c55742..8c68059ac1b0 100644 > --- a/fs/btrfs/subpage.c > +++ b/fs/btrfs/subpage.c > @@ -329,7 +329,7 @@ void btrfs_folio_end_lock_bitmap(const struct btrfs_fs_info *fs_info, > int cleared = 0; > int bit; > > - if (unlikely(!fs_info) || !btrfs_is_subpage(fs_info, folio->mapping)) { > + if (!btrfs_is_subpage(fs_info, folio->mapping)) { > folio_unlock(folio); > return; > }
diff --git a/fs/btrfs/subpage.c b/fs/btrfs/subpage.c index d4cab3c55742..8c68059ac1b0 100644 --- a/fs/btrfs/subpage.c +++ b/fs/btrfs/subpage.c @@ -329,7 +329,7 @@ void btrfs_folio_end_lock_bitmap(const struct btrfs_fs_info *fs_info, int cleared = 0; int bit; - if (unlikely(!fs_info) || !btrfs_is_subpage(fs_info, folio->mapping)) { + if (!btrfs_is_subpage(fs_info, folio->mapping)) { folio_unlock(folio); return; }