提交 2423fdfb 编写于 作者: J Jiri Slaby 提交者: Chris Mason

Btrfs, fix memory leaks in error paths

Stanse found 2 memory leaks in relocate_block_group and
__btrfs_map_block. cluster and multi are not freed/assigned on all
paths. Fix that.
Signed-off-by: NJiri Slaby <jslaby@suse.cz>
Cc: linux-btrfs@vger.kernel.org
Signed-off-by: NChris Mason <chris.mason@oracle.com>
上级 a038fab0
...@@ -3281,8 +3281,10 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc) ...@@ -3281,8 +3281,10 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
return -ENOMEM; return -ENOMEM;
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) if (!path) {
kfree(cluster);
return -ENOMEM; return -ENOMEM;
}
rc->extents_found = 0; rc->extents_found = 0;
rc->extents_skipped = 0; rc->extents_skipped = 0;
......
...@@ -2649,8 +2649,10 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, ...@@ -2649,8 +2649,10 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw,
em = lookup_extent_mapping(em_tree, logical, *length); em = lookup_extent_mapping(em_tree, logical, *length);
read_unlock(&em_tree->lock); read_unlock(&em_tree->lock);
if (!em && unplug_page) if (!em && unplug_page) {
kfree(multi);
return 0; return 0;
}
if (!em) { if (!em) {
printk(KERN_CRIT "unable to find logical %llu len %llu\n", printk(KERN_CRIT "unable to find logical %llu len %llu\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册