[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] tools/libxc: fix error handling in xc_mem_paging_load



# HG changeset patch
# User Olaf Hering <olaf@xxxxxxxxx>
# Date 1327575899 0
# Node ID d5b70621461696b2592eb3d22fa47cd738a26c90
# Parent  1e27e827e6a80b9fe8d59bcd46dbe30ca9bc0692
tools/libxc: fix error handling in xc_mem_paging_load

xc_mem_paging_load() does not pass errors in errno and the actual
errno from xc_mem_event_control() is overwritten by munlock().
xenpaging_populate_page() needs to check errno, but with the switch to
xc_mem_paging_load() it could not receive ENOMEM anymore.

Update xc_mem_paging_load() to return -1 and preserve errno during
munlock().

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
Acked-by: Andres Lagar-Cavilla <andres@xxxxxxxxxxxxxxxx>
Committed-by: Keir Fraser <keir@xxxxxxx>
---


diff -r 1e27e827e6a8 -r d5b706214616 tools/libxc/xc_mem_paging.c
--- a/tools/libxc/xc_mem_paging.c       Thu Jan 26 11:03:50 2012 +0000
+++ b/tools/libxc/xc_mem_paging.c       Thu Jan 26 11:04:59 2012 +0000
@@ -68,23 +68,28 @@
 int xc_mem_paging_load(xc_interface *xch, domid_t domain_id, 
                                 unsigned long gfn, void *buffer)
 {
-    int rc;
+    int rc, old_errno;
+
+    errno = -EINVAL;
 
     if ( !buffer )
-        return -EINVAL;
+        return -1;
 
     if ( ((unsigned long) buffer) & (XC_PAGE_SIZE - 1) )
-        return -EINVAL;
+        return -1;
 
     if ( mlock(buffer, XC_PAGE_SIZE) )
-        return -errno;
+        return -1;
         
     rc = xc_mem_event_control(xch, domain_id,
                                 XEN_DOMCTL_MEM_EVENT_OP_PAGING_PREP,
                                 XEN_DOMCTL_MEM_EVENT_OP_PAGING,
                                 buffer, NULL, gfn);
 
-    (void)munlock(buffer, XC_PAGE_SIZE);
+    old_errno = errno;
+    munlock(buffer, XC_PAGE_SIZE);
+    errno = old_errno;
+
     return rc;
 }
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.