linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] btrfs: reflink: Initialize return value in btrfs_extent_same()
@ 2021-08-20  0:41 Sidong Yang
  2021-08-20  6:08 ` Nikolay Borisov
  2021-08-23  9:44 ` Filipe Manana
  0 siblings, 2 replies; 7+ messages in thread
From: Sidong Yang @ 2021-08-20  0:41 UTC (permalink / raw)
  To: linux-btrfs, David Sterba, Nikolay Borisov; +Cc: Sidong Yang

btrfs_extent_same() cannot be called with zero length. This patch add
code that initialize ret as -EINVAL to make it safe.

Signed-off-by: Sidong Yang <realwakka@gmail.com>
---
v2:
 - Removed assert and added initializing ret
---
 fs/btrfs/reflink.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index 9b0814318e72..864f42198c5c 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;
 
+	ret = -EINVAL;
 	spin_lock(&root_dst->root_item_lock);
 	if (root_dst->send_in_progress) {
 		btrfs_warn_rl(root_dst->fs_info,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-08-26 14:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-20  0:41 [PATCH v2] btrfs: reflink: Initialize return value in btrfs_extent_same() Sidong Yang
2021-08-20  6:08 ` Nikolay Borisov
2021-08-20 11:17   ` David Sterba
2021-08-20 11:50     ` Sidong Yang
2021-08-23  9:44 ` Filipe Manana
2021-08-23 23:51   ` Sidong Yang
2021-08-26 14:08     ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).