diff options
author | David Sterba <dsterba@suse.cz> | 2011-04-19 10:45:00 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2011-05-02 07:57:20 -0400 |
commit | 4891aca2dac612a2f21a3278d9906ade13b55788 (patch) | |
tree | 6ec35a8d5cae40ab8755cd3e70d471e85827c87c /fs/btrfs/disk-io.c | |
parent | edc95aec57661c8e568e18f6c3f002aefa07ebc8 (diff) |
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: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 990afa8656a2..25e4b8f1d0ef 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1611,7 +1611,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1611 | struct btrfs_root *csum_root = kzalloc(sizeof(struct btrfs_root), | 1611 | struct btrfs_root *csum_root = kzalloc(sizeof(struct btrfs_root), |
1612 | GFP_NOFS); | 1612 | GFP_NOFS); |
1613 | struct btrfs_root *tree_root = btrfs_sb(sb); | 1613 | struct btrfs_root *tree_root = btrfs_sb(sb); |
1614 | struct btrfs_fs_info *fs_info = tree_root->fs_info; | 1614 | struct btrfs_fs_info *fs_info = NULL; |
1615 | struct btrfs_root *chunk_root = kzalloc(sizeof(struct btrfs_root), | 1615 | struct btrfs_root *chunk_root = kzalloc(sizeof(struct btrfs_root), |
1616 | GFP_NOFS); | 1616 | GFP_NOFS); |
1617 | struct btrfs_root *dev_root = kzalloc(sizeof(struct btrfs_root), | 1617 | struct btrfs_root *dev_root = kzalloc(sizeof(struct btrfs_root), |
@@ -1623,11 +1623,12 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1623 | 1623 | ||
1624 | struct btrfs_super_block *disk_super; | 1624 | struct btrfs_super_block *disk_super; |
1625 | 1625 | ||
1626 | if (!extent_root || !tree_root || !fs_info || | 1626 | if (!extent_root || !tree_root || !tree_root->fs_info || |
1627 | !chunk_root || !dev_root || !csum_root) { | 1627 | !chunk_root || !dev_root || !csum_root) { |
1628 | err = -ENOMEM; | 1628 | err = -ENOMEM; |
1629 | goto fail; | 1629 | goto fail; |
1630 | } | 1630 | } |
1631 | fs_info = tree_root->fs_info; | ||
1631 | 1632 | ||
1632 | ret = init_srcu_struct(&fs_info->subvol_srcu); | 1633 | ret = init_srcu_struct(&fs_info->subvol_srcu); |
1633 | if (ret) { | 1634 | if (ret) { |