Skip to contentSkip to conversation

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

PATCH In review Sidong Yang 3 participants 3 messages Nov 4, 2021 – Nov 30, 2021 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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

---
v2:
- Checks ret as well as trans

---
 check/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
check/main.c +1 -1
index 235a9bab..ddcc5c44 100644
@@ -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)
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · Sidong Yang

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

Quoted 21 lines

---
v2:
- Checks ret as well as trans

---
 check/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
check/main.c +1 -1
index 235a9bab..ddcc5c44 100644
@@ -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)
#2 lore raw
In reply to Sidong Yang
Quoted 9 lines · Sidong Yang

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

Added to devel, thanks.