Skip to contentSkip to conversation

btrfs: tests: Fix double free in remove_extent_ref()

PATCH In review Dan Carpenter 3 participants 3 messages Nov 27, 2025 – Nov 28, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: tests: Fix double free in remove_extent_ref()

We converted this code to use auto free cleanup.h magic but one old school free was accidentally left behind which leads to a double free bug.

Fixes a320476ca8a3 ("btrfs: tests: do trivial BTRFS_PATH_AUTO_FREE conversions")
---
 fs/btrfs/tests/qgroup-tests.c | 1 -
 1 file changed, 1 deletion(-)
fs/btrfs/tests/qgroup-tests.c +0 -1
index 05cfda8af422..e9124605974b 100644
@@ -187,7 +187,6 @@ static int remove_extent_ref(struct btrfs_root *root, u64 bytenr,
 	ret = btrfs_search_slot(&trans, root, &key, path, -1, 1);
 	if (ret) {
 		test_err("couldn't find backref %d", ret);
-		btrfs_free_path(path);
 		return ret;
 	}
 	btrfs_del_item(&trans, root, path);
Signature · 1 line
2.51.0
#1 lore raw
Quoted 6 lines · Dan Carpenter

We converted this code to use auto free cleanup.h magic but one old school free was accidentally left behind which leads to a double free bug.

Fixes a320476ca8a3 ("btrfs: tests: do trivial BTRFS_PATH_AUTO_FREE conversions")

Thanks, I'll add it to for-next as 6.19 branch is frozen.

#2 lore raw
In reply to Dan Carpenter

Thanks. My bad.

Quoted 22 lines · Dan Carpenter

We converted this code to use auto free cleanup.h magic but one old school free was accidentally left behind which leads to a double free bug.

Fixes a320476ca8a3 ("btrfs: tests: do trivial BTRFS_PATH_AUTO_FREE conversions")
---
 fs/btrfs/tests/qgroup-tests.c | 1 -
 1 file changed, 1 deletion(-)
fs/btrfs/tests/qgroup-tests.c +0 -1
index 05cfda8af422..e9124605974b 100644
@@ -187,7 +187,6 @@ static int remove_extent_ref(struct btrfs_root *root, u64 bytenr,
 	ret = btrfs_search_slot(&trans, root, &key, path, -1, 1);
 	if (ret) {
 		test_err("couldn't find backref %d", ret);
-		btrfs_free_path(path);
 		return ret;
 	}
 	btrfs_del_item(&trans, root, path);