Commit c367af44 authored by Zilin Guan's avatar Zilin Guan Committed by David Sterba
Browse files

btrfs: release root after error in data_reloc_print_warning_inode()



data_reloc_print_warning_inode() calls btrfs_get_fs_root() to obtain
local_root, but fails to release its reference when paths_from_inode()
returns an error. This causes a potential memory leak.

Add a missing btrfs_put_root() call in the error path to properly
decrease the reference count of local_root.

Fixes: b9a9a850 ("btrfs: output affected files when relocation fails")
CC: stable@vger.kernel.org # 6.6+
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarZilin Guan <zilin@seu.edu.cn>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 5fea61aa
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -177,8 +177,10 @@ static int data_reloc_print_warning_inode(u64 inum, u64 offset, u64 num_bytes,
		return ret;
	}
	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