Commit 23291a044c31f9dfdeaf633b631059fb75e5c2c4

Authored by Dan Carpenter
Committed by Chris Mason
1 parent 44c44af2f4

Btrfs: fix error handling in __add_reloc_root()

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>

Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff

fs/btrfs/relocation.c
... ... @@ -1239,10 +1239,11 @@
1239 1239 node->bytenr, &node->rb_node);
1240 1240 spin_unlock(&rc->reloc_root_tree.lock);
1241 1241 if (rb_node) {
1242   - kfree(node);
1243 1242 btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found "
1244 1243 "for start=%llu while inserting into relocation "
1245 1244 "tree\n");
  1245 + kfree(node);
  1246 + return -EEXIST;
1246 1247 }
1247 1248  
1248 1249 list_add_tail(&root->root_list, &rc->reloc_roots);