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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 28 Feb 2020 15:38:58 +0000 (16:38 +0100)
commit68b7db197bf8bbe33f377f034236b0149909f7eb
tree9a1a049b5f9cee4a2099715d4b66b53079109202
parent0ba8e5f347b275d2eb1e4b041b00ca1d2d79ae17
btrfs: reset fs_root to NULL on error in open_ctree

commit 315bf8ef914f31d51d084af950703aa1e09a728c upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/disk-io.c