diff options
author | chandan <chandan@linux.vnet.ibm.com> | 2015-10-05 22:14:25 +0530 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2015-10-06 06:55:22 -0700 |
commit | e5fffbac4a49270e4976d71a0e054c0cf3ef4f8e (patch) | |
tree | 66e59e0b269ac75097275d7632ef58060e11876f | |
parent | d9a0540a79f87456907f2ce031f058cf745c5bff (diff) | |
download | linux-e5fffbac4a49270e4976d71a0e054c0cf3ef4f8e.tar.bz2 |
Btrfs: open_ctree: Fix possible memory leak
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>
-rw-r--r-- | fs/btrfs/disk-io.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index aa59871885da..807f6854acaa 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -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; } @@ -2880,6 +2882,8 @@ retry_root_backup: !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; } |