Skip to content

Commit

Permalink
Btrfs: open_ctree: Fix possible memory leak
Browse files Browse the repository at this point in the history
After reading one of chunk or tree root tree's root node from disk, if the
root node does not have EXTENT_BUFFER_UPTODATE flag set, we fail to release
the memory used by the root node. Fix this.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
  • Loading branch information
chandan authored and Chris Mason committed Oct 6, 2015
1 parent d9a0540 commit e5fffba
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2842,6 +2842,8 @@ int open_ctree(struct super_block *sb,
!extent_buffer_uptodate(chunk_root->node)) {
printk(KERN_ERR "BTRFS: failed to read chunk root on %s\n",
sb->s_id);
if (!IS_ERR(chunk_root->node))
free_extent_buffer(chunk_root->node);
chunk_root->node = NULL;
goto fail_tree_roots;
}
Expand Down Expand Up @@ -2880,6 +2882,8 @@ int open_ctree(struct super_block *sb,
!extent_buffer_uptodate(tree_root->node)) {
printk(KERN_WARNING "BTRFS: failed to read tree root on %s\n",
sb->s_id);
if (!IS_ERR(tree_root->node))
free_extent_buffer(tree_root->node);
tree_root->node = NULL;
goto recovery_tree_root;
}
Expand Down

0 comments on commit e5fffba

Please sign in to comment.