VT-d: Fix resource leaks on error paths
PATCH 1/1 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 <[email protected]>
xen/drivers/passthrough/vtd/intremap.c +8 -2
@@ -210,7 +210,8 @@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 @@ 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 @@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 @@ 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 ; }
Looks good to me. ACK!
-----Original Message-----
From: Igor Mammedov [mailto:[email protected]]
Sent: Thursday, May 12, 2011 1:30 AM
To: [email protected]
Cc: Kay, Allen M; [email protected]
Subject: [Xen HV PATCH] 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 <[email protected]>
xen/drivers/passthrough/vtd/intremap.c +8 -2
@@ -210,7 +210,8 @@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 @@ 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 @@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 @@ 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 ; }