Thread (7 messages) 7 messages, 3 authors, 2021-08-20

[PATCH] btrfs: reflink: Assure length != 0 in btrfs_extent_same()

flat view
STALE1881d

From: Sidong Yang <hidden>
Date: 2021-08-18 16:08:31
Subsystem: btrfs file system, filesystems (vfs and infrastructure), the rest · Maintainers: David Sterba, Alexander Viro, Christian Brauner, Linus Torvalds

btrfs_extent_same() cannot be called with zero length. Because when
length is zero, it would be filtered by condition in
btrfs_remap_file_range(). But if this function is used in other case in
future, it can make ret as uninitialized.

Signed-off-by: Sidong Yang <redacted>
---
 fs/btrfs/reflink.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index 9b0814318e72..69eb50f2f0b4 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -653,6 +653,7 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
 	u64 i, tail_len, chunk_count;
 	struct btrfs_root *root_dst = BTRFS_I(dst)->root;
 
+	ASSERT(olen);
 	spin_lock(&root_dst->root_item_lock);
 	if (root_dst->send_in_progress) {
 		btrfs_warn_rl(root_dst->fs_info,
-- 
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help