]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: fix unexpected error path when reflinking an inline extent
authorFilipe Manana <fdmanana@suse.com>
Thu, 17 Feb 2022 12:12:07 +0000 (12:12 +0000)
committerDavid Sterba <dsterba@suse.com>
Mon, 14 Mar 2022 12:13:52 +0000 (13:13 +0100)
commit68214fa02098c6357984105ab42b618187b434c4
tree55bdfe9088c048df0c9e7a4f1759b139bf561ab9
parent5b0da33116e4a2017b459f9138f4131b1dfdc102
btrfs: fix unexpected error path when reflinking an inline extent

When reflinking an inline extent, we assert that its file offset is 0 and
that its uncompressed length is not greater than the sector size. We then
return an error if one of those conditions is not satisfied. However we
use a return statement, which results in returning from btrfs_clone()
without freeing the path and buffer that were allocated before, as well as
not clearing the flag BTRFS_INODE_NO_DELALLOC_FLUSH for the destination
inode.

Fix that by jumping to the 'out' label instead, and also add a WARN_ON()
for each condition so that in case assertions are disabled, we get to
known which of the unexpected conditions triggered the error.

Fixes: 983301cb8a6b2e ("Btrfs: simplify inline extent handling when doing reflinks")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/reflink.c