btrfs: fix possible NULL-pointer dereference in integrity checks
authorJohannes Thumshirn <jth@kernel.org>
Thu, 5 Dec 2019 13:19:57 +0000 (14:19 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Feb 2020 07:36:53 +0000 (08:36 +0100)
commitebf8e54118882ad17b81ddc457db1b979d6404ed
tree66cd9234095be849a53f4f4beb1f51b3b2c6a53a
parent50b93369668bb5e0f537ea8eb1ecf3fc702b5474
btrfs: fix possible NULL-pointer dereference in integrity checks

[ Upstream commit 3dbd351df42109902fbcebf27104149226a4fcd9 ]

A user reports a possible NULL-pointer dereference in
btrfsic_process_superblock(). We are assigning state->fs_info to a local
fs_info variable and afterwards checking for the presence of state.

While we would BUG_ON() a NULL state anyways, we can also just remove
the local fs_info copy, as fs_info is only used once as the first
argument for btrfs_num_copies(). There we can just pass in
state->fs_info as well.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=205003
Signed-off-by: Johannes Thumshirn <jth@kernel.org>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/btrfs/check-integrity.c