From: Denis V. Lunev Date: Wed, 26 Apr 2017 08:40:46 +0000 (+0300) Subject: block: fix alignment calculations in bdrv_co_do_zero_pwritev X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=f13ce1be35b13f09c0a28269c74468f6766f0365;p=qmiga%2Fqemu.git block: fix alignment calculations in bdrv_co_do_zero_pwritev 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 Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- diff --git a/block/io.c b/block/io.c index 80d6c62a85..40bd94f323 100644 --- a/block/io.c +++ b/block/io.c @@ -1444,7 +1444,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);