From: Ross Philipson Date: Wed, 6 Apr 2016 14:38:59 +0000 (+0100) Subject: blktap2: Invalid logic detecting unaligned buffers in vhd_write_block X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~1366 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=671361d40526cff052b97bfe16dc901d851899f0;p=xen.git blktap2: Invalid logic detecting unaligned buffers in vhd_write_block It seems the logic is meant to detect sector unaligned buffers for block writes. The NOTing of the logic instead masks off any unaligned bits and also would cause the function to always fail. It seems the function is not used in any of the tools so that is probably why the problem is not seen. In the vhd_read_block function it is correct. Signed-off-by: Ross Philipson Acked-by: Wei Liu --- diff --git a/tools/blktap2/vhd/lib/libvhd.c b/tools/blktap2/vhd/lib/libvhd.c index 1fd5b4eb9d..4ebe012acc 100644 --- a/tools/blktap2/vhd/lib/libvhd.c +++ b/tools/blktap2/vhd/lib/libvhd.c @@ -2188,7 +2188,7 @@ vhd_write_block(vhd_context_t *ctx, uint32_t block, char *data) if (block >= ctx->bat.entries) return -ERANGE; - if ((unsigned long)data & ~(VHD_SECTOR_SIZE -1)) + if ((unsigned long)data & (VHD_SECTOR_SIZE -1)) return -EINVAL; blk = ctx->bat.bat[block];