btrfs: reset fs_root to NULL on error in open_ctree
authorJosef Bacik <josef@toxicpanda.com>
Thu, 13 Feb 2020 15:47:28 +0000 (10:47 -0500)
committerDavid Sterba <dsterba@suse.com>
Tue, 18 Feb 2020 23:36:35 +0000 (00:36 +0100)
commit315bf8ef914f31d51d084af950703aa1e09a728c
tree4d592990138af7d7b60144f63b47563ae8c52f39
parent81f7eb00ff5bb8326e82503a32809421d14abb8a
btrfs: reset fs_root to NULL on error in open_ctree

While running my error injection script I hit a panic when we tried to
clean up the fs_root when freeing the fs_root.  This is because
fs_info->fs_root == PTR_ERR(-EIO), which isn't great.  Fix this by
setting fs_info->fs_root = NULL; if we fail to read the root.

CC: stable@vger.kernel.org # 4.4+
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/disk-io.c