ia64/xen-unstable

changeset 19675:ae5bd69227d1

Free pirq_array/pirq_to_evtchn in complete_domain_destroy().

Also rejig code slightly in domain_create().

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri May 29 09:26:49 2009 +0100 (2009-05-29)
parents 527b628b8e83
children 02cee9e4363e
files xen/common/domain.c
line diff
     1.1 --- a/xen/common/domain.c	Fri May 29 09:22:50 2009 +0100
     1.2 +++ b/xen/common/domain.c	Fri May 29 09:26:49 2009 +0100
     1.3 @@ -255,19 +255,20 @@ struct domain *domain_create(
     1.4          d->is_paused_by_controller = 1;
     1.5          atomic_inc(&d->pause_count);
     1.6  
     1.7 -        d->nr_pirqs = nr_irqs +
     1.8 -                      (domid ? extra_domU_irqs :
     1.9 -                               extra_dom0_irqs ?: nr_irqs);
    1.10 +        d->nr_pirqs = (nr_irqs +
    1.11 +                       (domid ? extra_domU_irqs :
    1.12 +                        extra_dom0_irqs ?: nr_irqs));
    1.13 +        d->pirq_to_evtchn = xmalloc_array(u16, d->nr_pirqs);
    1.14 +        d->pirq_mask = xmalloc_array(
    1.15 +            unsigned long, BITS_TO_LONGS(d->nr_pirqs));
    1.16 +        if ( (d->pirq_to_evtchn == NULL) || (d->pirq_mask == NULL) )
    1.17 +            goto fail;
    1.18 +        memset(d->pirq_to_evtchn, 0, d->nr_pirqs * sizeof(*d->pirq_to_evtchn));
    1.19 +        bitmap_zero(d->pirq_mask, d->nr_pirqs);
    1.20 +
    1.21          if ( evtchn_init(d) != 0 )
    1.22              goto fail;
    1.23          init_status |= INIT_evtchn;
    1.24 -        d->pirq_to_evtchn = xmalloc_array(u16, d->nr_pirqs);
    1.25 -        d->pirq_mask = xmalloc_array(unsigned long,
    1.26 -                                     BITS_TO_LONGS(d->nr_pirqs));
    1.27 -        if ( !d->pirq_to_evtchn || !d->pirq_mask )
    1.28 -            goto fail;
    1.29 -        memset(d->pirq_to_evtchn, 0, d->nr_pirqs * sizeof(*d->pirq_to_evtchn));
    1.30 -        bitmap_zero(d->pirq_mask, d->nr_pirqs);
    1.31  
    1.32          if ( grant_table_create(d) != 0 )
    1.33              goto fail;
    1.34 @@ -310,15 +311,13 @@ struct domain *domain_create(
    1.35      if ( init_status & INIT_gnttab )
    1.36          grant_table_destroy(d);
    1.37      if ( init_status & INIT_evtchn )
    1.38 -    {
    1.39 -        xfree(d->pirq_mask);
    1.40 -        xfree(d->pirq_to_evtchn);
    1.41          evtchn_destroy(d);
    1.42 -    }
    1.43      if ( init_status & INIT_rangeset )
    1.44          rangeset_domain_destroy(d);
    1.45      if ( init_status & INIT_xsm )
    1.46          xsm_free_security_domain(d);
    1.47 +    xfree(d->pirq_mask);
    1.48 +    xfree(d->pirq_to_evtchn);
    1.49      free_domain_struct(d);
    1.50      return NULL;
    1.51  }
    1.52 @@ -603,6 +602,9 @@ static void complete_domain_destroy(stru
    1.53      if ( d->target != NULL )
    1.54          put_domain(d->target);
    1.55  
    1.56 +    xfree(d->pirq_mask);
    1.57 +    xfree(d->pirq_to_evtchn);
    1.58 +
    1.59      xsm_free_security_domain(d);
    1.60      free_domain_struct(d);
    1.61