aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2020-02-11 16:40:39 -0500
committerJosef Bacik <josef@toxicpanda.com>2020-02-14 10:04:08 -0500
commit0f97c17b7082e5cb02a89036a0e679931443cb6d (patch)
tree90b6a1826e04641dbb19cd896001cccfe9f66abe
parent43ca3fed6aae44321e78494f1d4e08a0adfdee11 (diff)
downloadbtrfs-next-0f97c17b7082e5cb02a89036a0e679931443cb6d.tar.gz
btrfs: set fs_root = NULL on error
While running my error injection script I hit a panic when we tried to clean up the fs_root when free'ing 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. Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: Qu Wenruo <wqu@suse.com>
-rw-r--r--fs/btrfs/disk-io.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 1cb8535b8ba0e0..39a6bf158f6552 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3253,6 +3253,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
if (IS_ERR(fs_info->fs_root)) {
err = PTR_ERR(fs_info->fs_root);
btrfs_warn(fs_info, "failed to read fs tree: %d", err);
+ fs_info->fs_root = NULL;
goto fail_qgroup;
}