From: Sebastian Scherbel <sebastian.scherbel@xxxxxx>
Regarding Bug 205003, point 1
The struct "state" is currently dereferenced before being checked
for null later on. This patch moves the dereference after the null check
to avoid a possible null pointer dereference.
Signed-off-by: Sebastian Scherbel <sebastian.scherbel@xxxxxx>
Co-developed-by: Ole Wiedemann <ole.wiedemann@xxxxxx>
Signed-off-by: Ole Wiedemann <ole.wiedemann@xxxxxx>
---
fs/btrfs/check-integrity.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 0b52ab4cb964..fc429436765c 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -629,7 +629,7 @@ static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup(dev_t dev,
static int btrfsic_process_superblock(struct btrfsic_state *state,
struct btrfs_fs_devices *fs_devices)
{
- struct btrfs_fs_info *fs_info = state->fs_info;
+ struct btrfs_fs_info *fs_info;
struct btrfs_super_block *selected_super;
struct list_head *dev_head = &fs_devices->devices;
struct btrfs_device *device;
@@ -638,6 +638,8 @@ static int btrfsic_process_superblock(struct btrfsic_state *state,
int pass;
BUG_ON(NULL == state);
+ fs_info = state->fs_info;
+
selected_super = kzalloc(sizeof(*selected_super), GFP_NOFS);
if (NULL == selected_super) {
pr_info("btrfsic: error, kmalloc failed!\n");
--
2.20.1