Received: from eggs.gnu.org ([2001:4830:134:3::10]:54277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3IVQ-0004Ll-NG for qemu-devel@nongnu.org; Wed, 26 Apr 2017 04:41:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3IVP-00030d-UM for qemu-devel@nongnu.org; Wed, 26 Apr 2017 04:41:00 -0400 From: "Denis V. Lunev" Date: Wed, 26 Apr 2017 11:40:46 +0300 Message-Id: <1493196046-5607-1-git-send-email-den@openvz.org> Subject: [Qemu-devel] [PATCH 1/1] block: fix alignment calculations in bdrv_co_do_zero_pwritev List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Fam Zheng tail_padding_bytes is calculated wrong. F.e. for offset = 0 bytes = 2048 align = 512 we will have tail_padding_bytes = 512 which is definitely wrong. The patch fixes that arithmetics. Fortunately this problem is harmless, we will have 1 extra allocation and free thus there is no need to put this into stable. The problem is here from the very beginning. Signed-off-by: Denis V. Lunev CC: Stefan Hajnoczi CC: Fam Zheng --- block/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/io.c b/block/io.c index a7142e0..1e1523b 100644 --- a/block/io.c +++ b/block/io.c @@ -1452,7 +1452,7 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child, int ret = 0; head_padding_bytes = offset & (align - 1); - tail_padding_bytes = align - ((offset + bytes) & (align - 1)); + tail_padding_bytes = (align - (offset + bytes)) & (align - 1); assert(flags & BDRV_REQ_ZERO_WRITE); -- 2.7.4