Skip to content

Commit c367af4

Browse files
GoodLuck612kdave
authored andcommitted
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: b9a9a85 ("btrfs: output affected files when relocation fails") CC: stable@vger.kernel.org # 6.6+ Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Zilin Guan <zilin@seu.edu.cn> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 5fea61a commit c367af4

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

fs/btrfs/inode.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,10 @@ static int data_reloc_print_warning_inode(u64 inum, u64 offset, u64 num_bytes,
177177
return ret;
178178
}
179179
ret = paths_from_inode(inum, ipath);
180-
if (ret < 0)
180+
if (ret < 0) {
181+
btrfs_put_root(local_root);
181182
goto err;
183+
}
182184

183185
/*
184186
* We deliberately ignore the bit ipath might have been too small to

0 commit comments

Comments
 (0)