Skip to content

Commit 315bf8e

Browse files
josefbacikkdave
authored andcommitted
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: [email protected] # 4.4+ Reviewed-by: Nikolay Borisov <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 81f7eb0 commit 315bf8e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/btrfs/disk-io.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3200,6 +3200,7 @@ int __cold open_ctree(struct super_block *sb,
32003200
if (IS_ERR(fs_info->fs_root)) {
32013201
err = PTR_ERR(fs_info->fs_root);
32023202
btrfs_warn(fs_info, "failed to read fs tree: %d", err);
3203+
fs_info->fs_root = NULL;
32033204
goto fail_qgroup;
32043205
}
32053206

0 commit comments

Comments
 (0)