From 7f94ccb20a1a4c0a0622e94ab08e5338b538db95 Mon Sep 17 00:00:00 2001 From: Sidong Yang Date: Thu, 4 Nov 2021 14:16:10 +0000 Subject: [PATCH] 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 Signed-off-by: Sidong Yang Signed-off-by: David Sterba --- check/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check/main.c b/check/main.c index 5d1eed52..540130b8 100644 --- a/check/main.c +++ b/check/main.c @@ -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)