public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH next] btrfs: tests: Fix double free in remove_extent_ref()
@ 2025-11-27  7:14 Dan Carpenter
  2025-11-27 17:29 ` David Sterba
  2025-11-28  4:11 ` Sun Yangkai
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-11-27  7:14 UTC (permalink / raw)
  To: Sun YangKai
  Cc: Chris Mason, David Sterba, linux-btrfs, linux-kernel,
	kernel-janitors

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH next] btrfs: tests: Fix double free in remove_extent_ref()
  2025-11-27  7:14 [PATCH next] btrfs: tests: Fix double free in remove_extent_ref() Dan Carpenter
@ 2025-11-27 17:29 ` David Sterba
  2025-11-28  4:11 ` Sun Yangkai
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2025-11-27 17:29 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Sun YangKai, Chris Mason, David Sterba, linux-btrfs, linux-kernel,
	kernel-janitors

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH next] btrfs: tests: Fix double free in remove_extent_ref()
  2025-11-27  7:14 [PATCH next] btrfs: tests: Fix double free in remove_extent_ref() Dan Carpenter
  2025-11-27 17:29 ` David Sterba
@ 2025-11-28  4:11 ` Sun Yangkai
  1 sibling, 0 replies; 3+ messages in thread
From: Sun Yangkai @ 2025-11-28  4:11 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Chris Mason, David Sterba, linux-btrfs, linux-kernel,
	kernel-janitors

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);



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-11-28  4:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-27  7:14 [PATCH next] btrfs: tests: Fix double free in remove_extent_ref() Dan Carpenter
2025-11-27 17:29 ` David Sterba
2025-11-28  4:11 ` Sun Yangkai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox