From 88f21a0c2a4c8d59cf25ba2d6e6f13d6ce5a42ae Mon Sep 17 00:00:00 2001 From: Roger Pau Monne Date: Tue, 8 Nov 2016 17:22:15 +0100 Subject: [PATCH] libxc: fix unmap of ACPI guest memory region MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Commit fac7f7 changed the value of ptr so that it points to the right memory area, taking the page offset into account, but failed to remove this when doing the unmap, which caused the region to not be unmapped. Fix this by not modifying ptr and instead adding the page offset directly in the memcpy call. Coverity-ID: 1394285 Reported-by: Andrew Cooper Signed-off-by: Roger Pau Monné Reviewed-by: Boris Ostrovsky Reviewed-by: Andrew Cooper Acked-by: Wei Liu Release-acked-by: Wei Liu --- tools/libxc/xc_dom_core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c index ad819dd187..36cd3c8170 100644 --- a/tools/libxc/xc_dom_core.c +++ b/tools/libxc/xc_dom_core.c @@ -1119,10 +1119,9 @@ static int xc_dom_load_acpi(struct xc_dom_image *dom) goto err; } - ptr = (uint8_t *)ptr + - (dom->acpi_modules[i].guest_addr_out & ~XC_PAGE_MASK); - - memcpy(ptr, dom->acpi_modules[i].data, dom->acpi_modules[i].length); + memcpy((uint8_t *)ptr + + (dom->acpi_modules[i].guest_addr_out & ~XC_PAGE_MASK), + dom->acpi_modules[i].data, dom->acpi_modules[i].length); munmap(ptr, XC_PAGE_SIZE * num_pages); free(extents); -- 2.30.2