]> git.hungrycats.org Git - linux/commitdiff
Btrfs: open_ctree: Fix possible memory leak
authorchandan <chandan@linux.vnet.ibm.com>
Mon, 5 Oct 2015 16:44:25 +0000 (22:14 +0530)
committerZygo Blaxell <zblaxell@thirteen.furryterror.org>
Sat, 17 Oct 2015 03:17:36 +0000 (23:17 -0400)
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>
(cherry picked from commit e5fffbac4a49270e4976d71a0e054c0cf3ef4f8e)

fs/btrfs/disk-io.c

index d55705976cf472bca0abe8beea6aa19448e7a7c9..67d5375ec00d75b2570ae0a3b89aa728d2855ae7 100644 (file)
@@ -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;
        }