btrfs-progs/check
Qu Wenruo 650282a04c btrfs-progs: fix eb leak caused by missing btrfs_release_path() call.
[BUG]
Commit 06b6ad5e01 ("btrfs-progs: check: check for invalid free space
tree entries") makes btrfs check to report eb leakage even on newly
created btrfs:

 # mkfs.btrfs -f test.img
 # btrfs check test.img
  Opening filesystem to check...
  Checking filesystem on test.img
  UUID: 13c26b6a-3b2c-49b3-94c7-80bcfa4e494b
  [1/7] checking root items
  [2/7] checking extents
  [3/7] checking free space tree
  [4/7] checking fs roots
  [5/7] checking only csums items (without verifying data)
  [6/7] checking root refs
  [7/7] checking quota groups skipped (not enabled on this FS)
  found 147456 bytes used, no error found
  total csum bytes: 0
  total tree bytes: 147456
  total fs tree bytes: 32768
  total extent tree bytes: 16384
  btree space waste bytes: 140595
  file data blocks allocated: 0
   referenced 0
  extent buffer leak: start 30572544 len 16384 <<< Extent buffer leakage

[CAUSE]

The patch in mailinglist uses a dynamically allocated path while the
committed one has been converted to on-stack path, which is preferred.
However, the cleanup was not done properly.  We only release the path
inside the while loop, no at out label.  This means, if we hit error or
even just exhausted free space tree as expected, we will leak the path
to free space tree root.

Thus leading to the above leak report.

[FIX]
Fix the bug by calling btrfs_release_path() at out: label too.

This should make the code behave the same as the patch submitted to the
mailing list.

Fixes: 06b6ad5e01 ("btrfs-progs: check: check for invalid free space tree entries")
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2022-09-10 22:50:47 +02:00
..
common.h btrfs-progs: check: detect and fix invalid used for block groups 2021-08-25 15:38:54 +02:00
main.c btrfs-progs: fix eb leak caused by missing btrfs_release_path() call. 2022-09-10 22:50:47 +02:00
mode-common.c btrfs-progs: do not use btrfs_commit_transaction() just to update super blocks 2022-05-20 15:54:16 +02:00
mode-common.h btrfs-progs: check: add check and repair ability for super num devs mismatch 2022-03-24 00:36:13 +01:00
mode-lowmem.c btrfs-progs: check: lowmem, fix path leak when dev extents are invalid 2022-05-17 21:12:19 +02:00
mode-lowmem.h btrfs-progs: check btrfs_super_used in lowmem check 2021-08-25 15:38:54 +02:00
mode-original.h btrfs-progs: check: add check for overlong xattr names 2022-04-25 18:52:49 +02:00
qgroup-verify.c btrfs-progs: check: fix two error messages used in qgroup verification 2022-03-23 18:18:31 +01:00
qgroup-verify.h btrfs-progs: move ctree.c to kernel-shared/ 2020-08-31 17:01:05 +02:00