aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/event_channel.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2009-05-27 14:03:09 +0100
committerKeir Fraser <keir.fraser@citrix.com>2009-05-27 14:03:09 +0100
commit5cb81a39e5636226f223fd67f11cfe14a039684a (patch)
tree99fecc184b7aed6774f27b275675c1a42183f28c /xen/common/event_channel.c
parentb0a6b122934267f2e9ab0b19a000bde4cf7170b8 (diff)
downloadxen-5cb81a39e5636226f223fd67f11cfe14a039684a.tar.gz
xen-5cb81a39e5636226f223fd67f11cfe14a039684a.tar.bz2
xen-5cb81a39e5636226f223fd67f11cfe14a039684a.zip
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@citrix.com>
Diffstat (limited to 'xen/common/event_channel.c')
-rw-r--r--xen/common/event_channel.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
index c51fd10031..f4ea79f4b2 100644
--- a/xen/common/event_channel.c
+++ b/xen/common/event_channel.c
@@ -1013,10 +1013,27 @@ void notify_via_xen_event_channel(int lport)
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)