Skip to content

Commit e682342

Browse files
kdavemehmetb0
authored andcommitted
btrfs: send: handle unexpected data in header buffer in begin_cmd()
BugLink: https://bugs.launchpad.net/bugs/2084005 [ Upstream commit e80e3f732cf53c64b0d811e1581470d67f6c3228 ] Change BUG_ON to a proper error handling in the unlikely case of seeing data when the command is started. This is supposed to be reset when the command is finished (send_cmd, send_encoded_extent). Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Koichiro Den <koichiro.den@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 8137836 commit e682342

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

fs/btrfs/send.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,12 @@ static int begin_cmd(struct send_ctx *sctx, int cmd)
777777
if (WARN_ON(!sctx->send_buf))
778778
return -EINVAL;
779779

780-
BUG_ON(sctx->send_size);
780+
if (unlikely(sctx->send_size != 0)) {
781+
btrfs_err(sctx->send_root->fs_info,
782+
"send: command header buffer not empty cmd %d offset %llu",
783+
cmd, sctx->send_off);
784+
return -EINVAL;
785+
}
781786

782787
sctx->send_size += sizeof(*hdr);
783788
hdr = (struct btrfs_cmd_header *)sctx->send_buf;

0 commit comments

Comments
 (0)