Skip to content

Commit

Permalink
Btrfs: fix error handling in __add_reloc_root()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dan Carpenter authored and Chris Mason committed Jul 23, 2012
1 parent 44c44af commit 23291a0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/btrfs/relocation.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 23291a0

Please sign in to comment.