btrfs: Error handle for get_ref_objectid_v0() in relocate_block_group()

We need error checking code for get_ref_objectid_v0() in
relocate_block_group(), to avoid unpredictable result, especially
for accessing uninitialized value(when function failed) after
this line.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
This commit is contained in:
Zhaolei 2015-08-05 18:00:02 +08:00 committed by Chris Mason
parent 55e3a601c8
commit 4b3576e450
1 changed files with 4 additions and 0 deletions

View File

@ -3976,6 +3976,10 @@ restart:
sizeof(struct btrfs_extent_item_v0));
ret = get_ref_objectid_v0(rc, path, &key, &ref_owner,
&path_change);
if (ret < 0) {
err = ret;
break;
}
if (ref_owner < BTRFS_FIRST_FREE_OBJECTID)
flags = BTRFS_EXTENT_FLAG_TREE_BLOCK;
else