WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

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

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] tools/xenpaging: Fix some memory leaks on error paths.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 30 Jul 2010 01:45:23 -0700
Delivery-date: Fri, 30 Jul 2010 01:47:16 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# 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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] tools/xenpaging: Fix some memory leaks on error paths., Xen patchbot-unstable <=