Btrfs: fix possible memory leaks in open_ctree()
Fix possible memory leaks in the following error handling paths: read_tree_block() btrfs_recover_log_trees btrfs_commit_super() btrfs_find_orphan_roots() btrfs_cleanup_fs_roots() Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: Chris Mason <clm@fb.com>
This commit is contained in:
parent
e60efa8425
commit
28c16cbbc3
|
@ -2864,7 +2864,7 @@ int open_ctree(struct super_block *sb,
|
||||||
printk(KERN_ERR "BTRFS: failed to read log tree\n");
|
printk(KERN_ERR "BTRFS: failed to read log tree\n");
|
||||||
free_extent_buffer(log_tree_root->node);
|
free_extent_buffer(log_tree_root->node);
|
||||||
kfree(log_tree_root);
|
kfree(log_tree_root);
|
||||||
goto fail_trans_kthread;
|
goto fail_qgroup;
|
||||||
}
|
}
|
||||||
/* returns with log_tree_root freed on success */
|
/* returns with log_tree_root freed on success */
|
||||||
ret = btrfs_recover_log_trees(log_tree_root);
|
ret = btrfs_recover_log_trees(log_tree_root);
|
||||||
|
@ -2873,24 +2873,24 @@ int open_ctree(struct super_block *sb,
|
||||||
"Failed to recover log tree");
|
"Failed to recover log tree");
|
||||||
free_extent_buffer(log_tree_root->node);
|
free_extent_buffer(log_tree_root->node);
|
||||||
kfree(log_tree_root);
|
kfree(log_tree_root);
|
||||||
goto fail_trans_kthread;
|
goto fail_qgroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sb->s_flags & MS_RDONLY) {
|
if (sb->s_flags & MS_RDONLY) {
|
||||||
ret = btrfs_commit_super(tree_root);
|
ret = btrfs_commit_super(tree_root);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto fail_trans_kthread;
|
goto fail_qgroup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = btrfs_find_orphan_roots(tree_root);
|
ret = btrfs_find_orphan_roots(tree_root);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto fail_trans_kthread;
|
goto fail_qgroup;
|
||||||
|
|
||||||
if (!(sb->s_flags & MS_RDONLY)) {
|
if (!(sb->s_flags & MS_RDONLY)) {
|
||||||
ret = btrfs_cleanup_fs_roots(fs_info);
|
ret = btrfs_cleanup_fs_roots(fs_info);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto fail_trans_kthread;
|
goto fail_qgroup;
|
||||||
|
|
||||||
ret = btrfs_recover_relocation(tree_root);
|
ret = btrfs_recover_relocation(tree_root);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
|
Loading…
Reference in New Issue