Skip to content

Commit 1272609

Browse files
GoodLuck612gregkh
authored andcommitted
btrfs: release root after error in data_reloc_print_warning_inode()
commit c367af4 upstream. 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: [email protected] # 6.6+ Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Zilin Guan <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1ab78aa commit 1272609

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/btrfs/inode.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,10 @@ static int data_reloc_print_warning_inode(u64 inum, u64 offset, u64 num_bytes,
174174
return ret;
175175
}
176176
ret = paths_from_inode(inum, ipath);
177-
if (ret < 0)
177+
if (ret < 0) {
178+
btrfs_put_root(local_root);
178179
goto err;
180+
}
179181

180182
/*
181183
* We deliberately ignore the bit ipath might have been too small to

0 commit comments

Comments
 (0)