]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Btrfs: fix error handling in __add_reloc_root()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 25 Jun 2012 11:15:23 +0000 (05:15 -0600)
committerChris Mason <chris.mason@fusionio.com>
Mon, 23 Jul 2012 20:27:53 +0000 (16:27 -0400)
We dereferenced "node" in the error message after freeing it.  Also
btrfs_panic() can return so we should return an error code instead of
continuing.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
fs/btrfs/relocation.c

index 646ee21bb035d9ad8a4b1628e6883544c0603ea6..c5dbd91496790a3279b8044552f6664666b68a52 100644 (file)
@@ -1239,10 +1239,11 @@ static int __must_check __add_reloc_root(struct btrfs_root *root)
                              node->bytenr, &node->rb_node);
        spin_unlock(&rc->reloc_root_tree.lock);
        if (rb_node) {
-               kfree(node);
                btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found "
                            "for start=%llu while inserting into relocation "
                            "tree\n");
+               kfree(node);
+               return -EEXIST;
        }
 
        list_add_tail(&root->root_list, &rc->reloc_roots);