btrfs-progs: check: change commit condition in fixup_extent_refs()

This patch fixes potential bugs in fixup_extent_refs(). If
btrfs_start_transaction() fails in some way and returns error ptr, It
goes to out logic. But old code checkes whether it is null and it calls
commit. This patch solves the problem with make that it calls only if
ret is no error.

Issue: #409
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Sidong Yang <realwakka@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Sidong Yang 2021-11-04 14:16:10 +00:00 committed by David Sterba
parent 5e8a779f5c
commit 7f94ccb20a
1 changed files with 1 additions and 1 deletions

View File

@ -7773,7 +7773,7 @@ static int fixup_extent_refs(struct cache_tree *extent_cache,
goto out;
}
out:
if (trans) {
if (!ret && !IS_ERR(trans)) {
int err = btrfs_commit_transaction(trans, gfs_info->tree_root);
if (!ret)