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

[Xen-changelog] [xen-unstable] tools/xenpaging: Fix some memory leaks on error paths.



# HG changeset patch
# User Patrick Colp <pjcolp@xxxxxxxxx>
# Date 1280418820 -3600
# Node ID 3263d0ff9476f574961a3975897fe33601253b56
# Parent  4a4d9e3ca3ef08c19bb54628d2cc5f394f9ce44e
tools/xenpaging: Fix some memory leaks on error paths.

This isn't directly related to EPT checking, but does some general fix-ups
to the xenpaging code (adds some extra frees, etc.)

Signed-off-by: Patrick Colp <pjcolp@xxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/xenpaging/xenpaging.c |   31 ++++++++++++++++++++++++-------
 1 files changed, 24 insertions(+), 7 deletions(-)

diff -r 4a4d9e3ca3ef -r 3263d0ff9476 tools/xenpaging/xenpaging.c
--- a/tools/xenpaging/xenpaging.c       Thu Jul 29 16:40:47 2010 +0100
+++ b/tools/xenpaging/xenpaging.c       Thu Jul 29 16:53:40 2010 +0100
@@ -73,8 +73,9 @@ xenpaging_t *xenpaging_init(xc_interface
     xc_interface *xch;
     int rc;
 
-    xch = xc_interface_open(0,0,0);
-    if ( !xch ) return NULL;
+    xch = xc_interface_open(NULL, NULL, 0);
+    if ( !xch )
+        goto err_iface;
 
     DPRINTF("xenpaging init\n");
     *xch_r = xch;
@@ -101,7 +102,7 @@ xenpaging_t *xenpaging_init(xc_interface
     paging->mem_event.ring_page = init_page();
     if ( paging->mem_event.ring_page == NULL )
     {
-        ERROR("Error initialising shared page");
+        ERROR("Error initialising ring page");
         goto err;
     }
 
@@ -199,13 +200,27 @@ xenpaging_t *xenpaging_init(xc_interface
     return paging;
 
  err:
-    if ( paging->bitmap )
+    if ( paging )
+    {
+        if ( paging->mem_event.shared_page )
+        {
+            munlock(paging->mem_event.shared_page, PAGE_SIZE);
+            free(paging->mem_event.shared_page);
+        }
+
+        if ( paging->mem_event.ring_page )
+        {
+            munlock(paging->mem_event.ring_page, PAGE_SIZE);
+            free(paging->mem_event.ring_page);
+        }
+
         free(paging->bitmap);
-    if ( paging->platform_info )
         free(paging->platform_info);
-    if ( paging )
+        free(paging->domain_info);
         free(paging);
-
+    }
+
+ err_iface: 
     return NULL;
 }
 
@@ -619,6 +634,8 @@ int main(int argc, char *argv[])
     if ( rc == 0 )
         rc = rc1;
 
+    xc_interface_close(xch);
+
     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®.