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

[Xen-changelog] [xen-unstable] evtchn: Free pirq_to_evtchn/pirq_mask arrays on domain destruction.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1243429389 -3600
# Node ID 326b24bfa9f92b805f7da8fc369af8e721cf707a
# Parent  649226acc47e8b670fbb7ea889c753fef430e455
evtchn: Free pirq_to_evtchn/pirq_mask arrays on domain destruction.

At the same time, move this into evtchn_init/destroy().

Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 xen/common/domain.c        |   11 -----------
 xen/common/event_channel.c |   24 +++++++++++++++++++++++-
 2 files changed, 23 insertions(+), 12 deletions(-)

diff -r 649226acc47e -r 326b24bfa9f9 xen/common/domain.c
--- a/xen/common/domain.c       Wed May 27 12:00:51 2009 +0100
+++ b/xen/common/domain.c       Wed May 27 14:03:09 2009 +0100
@@ -261,13 +261,6 @@ struct domain *domain_create(
         if ( evtchn_init(d) != 0 )
             goto fail;
         init_status |= INIT_evtchn;
-        d->pirq_to_evtchn = xmalloc_array(u16, d->nr_pirqs);
-        d->pirq_mask = xmalloc_array(unsigned long,
-                                     BITS_TO_LONGS(d->nr_pirqs));
-        if ( !d->pirq_to_evtchn || !d->pirq_mask )
-            goto fail;
-        memset(d->pirq_to_evtchn, 0, d->nr_pirqs * sizeof(*d->pirq_to_evtchn));
-        bitmap_zero(d->pirq_mask, d->nr_pirqs);
 
         if ( grant_table_create(d) != 0 )
             goto fail;
@@ -310,11 +303,7 @@ struct domain *domain_create(
     if ( init_status & INIT_gnttab )
         grant_table_destroy(d);
     if ( init_status & INIT_evtchn )
-    {
-        xfree(d->pirq_mask);
-        xfree(d->pirq_to_evtchn);
         evtchn_destroy(d);
-    }
     if ( init_status & INIT_rangeset )
         rangeset_domain_destroy(d);
     if ( init_status & INIT_xsm )
diff -r 649226acc47e -r 326b24bfa9f9 xen/common/event_channel.c
--- a/xen/common/event_channel.c        Wed May 27 12:00:51 2009 +0100
+++ b/xen/common/event_channel.c        Wed May 27 14:03:09 2009 +0100
@@ -1013,10 +1013,27 @@ int evtchn_init(struct domain *d)
 int evtchn_init(struct domain *d)
 {
     spin_lock_init(&d->event_lock);
+
+    d->pirq_to_evtchn = xmalloc_array(u16, d->nr_pirqs);
+    d->pirq_mask = xmalloc_array(
+        unsigned long, BITS_TO_LONGS(d->nr_pirqs));
+    if ( (d->pirq_to_evtchn == NULL) || (d->pirq_mask == NULL) )
+        goto fail;
+    memset(d->pirq_to_evtchn, 0, d->nr_pirqs * sizeof(*d->pirq_to_evtchn));
+    bitmap_zero(d->pirq_mask, d->nr_pirqs);
+
     if ( get_free_port(d) != 0 )
-        return -EINVAL;
+        goto fail;
     evtchn_from_port(d, 0)->state = ECS_RESERVED;
+
     return 0;
+
+ fail:
+    xfree(d->pirq_to_evtchn);
+    d->pirq_to_evtchn = NULL;
+    xfree(d->pirq_mask);
+    d->pirq_mask = NULL;
+    return -ENOMEM;
 }
 
 
@@ -1044,6 +1061,11 @@ void evtchn_destroy(struct domain *d)
         d->evtchn[i] = NULL;
     }
     spin_unlock(&d->event_lock);
+
+    xfree(d->pirq_to_evtchn);
+    d->pirq_to_evtchn = NULL;
+    xfree(d->pirq_mask);
+    d->pirq_mask = NULL;
 }
 
 static void domain_dump_evtchn_info(struct domain *d)

_______________________________________________
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®.