diff options
author | Igor Mammedov <imammedo@redhat.com> | 2011-05-16 13:38:09 +0100 |
---|---|---|
committer | Igor Mammedov <imammedo@redhat.com> | 2011-05-16 13:38:09 +0100 |
commit | 3a9c9ab052c2175ea9015a5809cbdbd0d0286d78 (patch) | |
tree | f588dc573505a8bfa642cc299587a061f0284779 | |
parent | b9b9d411d763218683e3480b4c8ea9bd008838bd (diff) | |
download | xen-3a9c9ab052c2175ea9015a5809cbdbd0d0286d78.tar.gz xen-3a9c9ab052c2175ea9015a5809cbdbd0d0286d78.tar.bz2 xen-3a9c9ab052c2175ea9015a5809cbdbd0d0286d78.zip |
VT-d: Fix resource leaks on error paths
On error exit from functions, maped pages should be unmapped
and acquired locks released.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Allen Kay <allen.m.kay@intel.com>
xen-unstable changeset: 23343:edcf8fc77b64
xen-unstable date: Mon May 16 13:29:24 2011 +0100
-rw-r--r-- | xen/drivers/passthrough/vtd/intremap.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrough/vtd/intremap.c index 7e194a4927..d91700fcee 100644 --- a/xen/drivers/passthrough/vtd/intremap.c +++ b/xen/drivers/passthrough/vtd/intremap.c @@ -210,7 +210,8 @@ static int alloc_remap_entry(struct iommu *iommu) if ( iremap_entries ) unmap_vtd_domain_page(iremap_entries); - ir_ctrl->iremap_num++; + if ( i < IREMAP_ENTRY_NR ) + ir_ctrl->iremap_num++; return i; } @@ -246,6 +247,8 @@ static int remap_entry_to_ioapic_rte( dprintk(XENLOG_ERR VTDPREFIX, "%s: index (%d) get an empty entry!\n", __func__, index); + unmap_vtd_domain_page(iremap_entries); + spin_unlock_irqrestore(&ir_ctrl->iremap_lock, flags); return -EFAULT; } @@ -281,7 +284,8 @@ static int ioapic_rte_to_remap_entry(struct iommu *iommu, if ( index < 0 ) { index = alloc_remap_entry(iommu); - apic_pin_2_ir_idx[apic][ioapic_pin] = index; + if ( index < IREMAP_ENTRY_NR ) + apic_pin_2_ir_idx[apic][ioapic_pin] = index; } if ( index > IREMAP_ENTRY_NR - 1 ) @@ -546,6 +550,8 @@ static int remap_entry_to_msi_msg( dprintk(XENLOG_ERR VTDPREFIX, "%s: index (%d) get an empty entry!\n", __func__, index); + unmap_vtd_domain_page(iremap_entries); + spin_unlock_irqrestore(&ir_ctrl->iremap_lock, flags); return -EFAULT; } |