From: Wei Yang Date: Fri, 12 Jul 2019 03:27:04 +0000 (+0800) Subject: migration: check length directly to make sure the range is aligned X-Git-Tag: v5.0.0-rc0~175^2~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=72821d93e0cc8c017bf387d2f8826a827cd6dc15;p=thirdparty%2Fqemu.git migration: check length directly to make sure the range is aligned Since the start addr is already checked, to make sure the range is aligned, checking the length is enough. Signed-off-by: Wei Yang Reviewed-by: Dr. David Alan Gilbert Message-Id: <20190712032704.7826-1-richardw.yang@linux.intel.com> Signed-off-by: Paolo Bonzini --- diff --git a/exec.c b/exec.c index a34c3481840..dfe2096d4a7 100644 --- a/exec.c +++ b/exec.c @@ -3901,10 +3901,9 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length) if ((start + length) <= rb->used_length) { bool need_madvise, need_fallocate; - uint8_t *host_endaddr = host_startaddr + length; - if ((uintptr_t)host_endaddr & (rb->page_size - 1)) { - error_report("ram_block_discard_range: Unaligned end address: %p", - host_endaddr); + if (length & (rb->page_size - 1)) { + error_report("ram_block_discard_range: Unaligned length: %zx", + length); goto err; }