[PATCH next] btrfs: tests: Fix double free in remove_extent_ref()

Dan Carpenter posted 1 patch 4 days, 14 hours ago
fs/btrfs/tests/qgroup-tests.c | 1 -
1 file changed, 1 deletion(-)
[PATCH next] btrfs: tests: Fix double free in remove_extent_ref()
Posted by Dan Carpenter 4 days, 14 hours ago
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")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 fs/btrfs/tests/qgroup-tests.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/btrfs/tests/qgroup-tests.c b/fs/btrfs/tests/qgroup-tests.c
index 05cfda8af422..e9124605974b 100644
--- a/fs/btrfs/tests/qgroup-tests.c
+++ b/fs/btrfs/tests/qgroup-tests.c
@@ -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);
-- 
2.51.0
Re: [PATCH next] btrfs: tests: Fix double free in remove_extent_ref()
Posted by Sun Yangkai 3 days, 17 hours ago
Thanks. My bad.

在 2025/11/27 15:14, 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  fs/btrfs/tests/qgroup-tests.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/fs/btrfs/tests/qgroup-tests.c b/fs/btrfs/tests/qgroup-tests.c
> index 05cfda8af422..e9124605974b 100644
> --- a/fs/btrfs/tests/qgroup-tests.c
> +++ b/fs/btrfs/tests/qgroup-tests.c
> @@ -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);


Re: [PATCH next] btrfs: tests: Fix double free in remove_extent_ref()
Posted by David Sterba 4 days, 4 hours ago
On Thu, Nov 27, 2025 at 10:14:24AM +0300, Dan Carpenter wrote:
> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

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