]> git.proxmox.com Git - mirror_ubuntu-jammy-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)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 20 May 2022 12:38:07 +0000 (14:38 +0200)
commit0209568b1cde64da796b27a7dd2d7a290d4998a8
tree65cf52ab53af9fa3bc1df90136e67e2cd54d612c
parenta4e317dbace1341a9c11f3f0dd617ac936b7266c
btrfs: fix unexpected error path when reflinking an inline extent

BugLink: https://bugs.launchpad.net/bugs/1969110
[ Upstream commit 1f4613cdbe7739ce291554b316bff8e551383389 ]

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: a61e1e0df9f321 ("Btrfs: simplify inline extent handling when doing reflinks")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 1a97987f76b404c684caaba15485d0412923c621)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
fs/btrfs/reflink.c