Re: [PATCH v2] btrfs-progs: check: change commit condition in fixup_extent_refs()
From: Nikolay Borisov <hidden>
Date: 2021-11-05 12:28:05
From: Nikolay Borisov <hidden>
Date: 2021-11-05 12:28:05
On 4.11.21 г. 16:16, Sidong Yang wrote:
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 Signed-off-by: Sidong Yang <redacted>
Reviewed-by: Nikolay Borisov <redacted>
--- v2: - Checks ret as well as trans --- check/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)diff --git a/check/main.c b/check/main.c index 235a9bab..ddcc5c44 100644 --- a/check/main.c +++ b/check/main.c@@ -7735,7 +7735,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->extent_root); if (!ret)