# HG changeset patch # User yamahata@xxxxxxxxxxxxx # Date 1177397835 -32400 # Node ID c37b86988e2bcbba7658d684ccefa175420e9b2c # Parent 16c51e377085815906c49413f46bae6877f0a645 fix xen/ia64 save/restore error recovery path. PATCHNAME: fix_xen_ia64_save_restore_error_recovery Signed-off-by: Isaku Yamahata diff -r 16c51e377085 -r c37b86988e2b tools/libxc/ia64/xc_ia64_linux_restore.c --- a/tools/libxc/ia64/xc_ia64_linux_restore.c Tue May 08 16:24:47 2007 +0900 +++ b/tools/libxc/ia64/xc_ia64_linux_restore.c Tue Apr 24 15:57:15 2007 +0900 @@ -52,7 +52,8 @@ read_page(int xc_handle, int io_fd, uint } if (!read_exact(io_fd, mem, PAGE_SIZE)) { ERROR("Error when reading from state file (5)"); - return -1; + munmap(mem, PAGE_SIZE); + return -1; } munmap(mem, PAGE_SIZE); return 0; @@ -270,6 +271,7 @@ xc_domain_restore(int xc_handle, int io_ } if (!read_exact(io_fd, shared_info, PAGE_SIZE)) { ERROR("Error when reading shared_info page"); + munmap(shared_info, PAGE_SIZE); goto out; } @@ -286,6 +288,10 @@ xc_domain_restore(int xc_handle, int io_ /* Uncanonicalise the suspend-record frame number and poke resume rec. */ start_info = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE, gmfn); + if (start_info == NULL) { + ERROR("cannot map start_info page"); + goto out; + } start_info->nr_pages = p2m_size; start_info->shared_info = shared_info_frame << PAGE_SHIFT; start_info->flags = 0; diff -r 16c51e377085 -r c37b86988e2b tools/libxc/ia64/xc_ia64_linux_save.c --- a/tools/libxc/ia64/xc_ia64_linux_save.c Tue May 08 16:24:47 2007 +0900 +++ b/tools/libxc/ia64/xc_ia64_linux_save.c Tue Apr 24 15:57:15 2007 +0900 @@ -361,11 +361,13 @@ xc_domain_save(int xc_handle, int io_fd, if (!write_exact(io_fd, &N, sizeof(N))) { ERROR("write: max_pfn"); + munmap(mem, PAGE_SIZE); goto out; } if (write(io_fd, mem, PAGE_SIZE) != PAGE_SIZE) { ERROR("Error when writing to state file (5)"); + munmap(mem, PAGE_SIZE); goto out; } munmap(mem, PAGE_SIZE); @@ -470,6 +472,7 @@ xc_domain_save(int xc_handle, int io_fd, } if (write(io_fd, mem, PAGE_SIZE) != PAGE_SIZE) { ERROR("Error when writing privreg to state file (5)"); + munmap(mem, PAGE_SIZE); goto out; } munmap(mem, PAGE_SIZE);