Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH] btrfs: Fix local_root reference leak in scrub_print_warning_inode()
@ 2026-09-16 17:16 Wentao Liang
  2026-09-16 21:44 ` Qu Wenruo
  2026-09-21 12:28 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-09-16 17:16 UTC (permalink / raw)
  To: clm; +Cc: dsterba, linux-btrfs, linux-kernel, list.btrfs, Wentao Liang,
	stable

When paths_from_inode() fails, scrub_print_warning_inode() jumps to
err without dropping the reference taken by btrfs_get_fs_root(),
leaking a reference to the root every time path resolution fails while
printing scrub warnings.  Every other error and success path of the
function drops the reference.

Drop the reference on the paths_from_inode() failure path too.

Fixes: 558540c17771 ("btrfs scrub: print paths of corrupted files")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 fs/btrfs/scrub.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 1ac609239cbe..570828ec780b 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -549,8 +549,10 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 num_bytes,
 	}
 	ret = paths_from_inode(inum, ipath);
 
-	if (ret < 0)
+	if (ret < 0) {
+		btrfs_put_root(local_root);
 		goto err;
+	}
 
 	/*
 	 * we deliberately ignore the bit ipath might have been too small to
-- 
2.34.1


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

end of thread, other threads:[~2026-09-21 12:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-16 17:16 [PATCH] btrfs: Fix local_root reference leak in scrub_print_warning_inode() Wentao Liang
2026-09-16 21:44 ` Qu Wenruo
2026-09-21 12:28 ` David Sterba

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