提交 4891aca2 编写于 作者: D David Sterba

btrfs: fix dereference before check

The superblock's ->s_fs_info is properly set in btrfs_fill_super, after
a call to open_ctree, which derefereces it before check. Although
tree_root is set via btrfs_set_super, let's be defensive and leave the
check in place.
Signed-off-by: NDavid Sterba <dsterba@suse.cz>
上级 edc95aec
...@@ -1611,7 +1611,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, ...@@ -1611,7 +1611,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
struct btrfs_root *csum_root = kzalloc(sizeof(struct btrfs_root), struct btrfs_root *csum_root = kzalloc(sizeof(struct btrfs_root),
GFP_NOFS); GFP_NOFS);
struct btrfs_root *tree_root = btrfs_sb(sb); struct btrfs_root *tree_root = btrfs_sb(sb);
struct btrfs_fs_info *fs_info = tree_root->fs_info; struct btrfs_fs_info *fs_info = NULL;
struct btrfs_root *chunk_root = kzalloc(sizeof(struct btrfs_root), struct btrfs_root *chunk_root = kzalloc(sizeof(struct btrfs_root),
GFP_NOFS); GFP_NOFS);
struct btrfs_root *dev_root = kzalloc(sizeof(struct btrfs_root), struct btrfs_root *dev_root = kzalloc(sizeof(struct btrfs_root),
...@@ -1623,11 +1623,12 @@ struct btrfs_root *open_ctree(struct super_block *sb, ...@@ -1623,11 +1623,12 @@ struct btrfs_root *open_ctree(struct super_block *sb,
struct btrfs_super_block *disk_super; struct btrfs_super_block *disk_super;
if (!extent_root || !tree_root || !fs_info || if (!extent_root || !tree_root || !tree_root->fs_info ||
!chunk_root || !dev_root || !csum_root) { !chunk_root || !dev_root || !csum_root) {
err = -ENOMEM; err = -ENOMEM;
goto fail; goto fail;
} }
fs_info = tree_root->fs_info;
ret = init_srcu_struct(&fs_info->subvol_srcu); ret = init_srcu_struct(&fs_info->subvol_srcu);
if (ret) { if (ret) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册