From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Kay, Allen M" Subject: RE: [Xen HV PATCH] VT-d: Fix resource leaks on error paths Date: Fri, 13 May 2011 10:48:48 -0700 Message-ID: <987664A83D2D224EAE907B061CE93D5301CD0E26EF@orsmsx505.amr.corp.intel.com> References: <1305189007-16043-1-git-send-email-imammedo@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <1305189007-16043-1-git-send-email-imammedo@redhat.com> Content-Language: en-US List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Igor Mammedov , "xen-devel@lists.xensource.com" Cc: "keir@xen.org" List-Id: xen-devel@lists.xenproject.org Looks good to me. ACK! -----Original Message----- From: Igor Mammedov [mailto:imammedo@redhat.com]=20 Sent: Thursday, May 12, 2011 1:30 AM To: xen-devel@lists.xensource.com Cc: Kay, Allen M; keir@xen.org 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 diff -r 4b0692880dfa -r da93d9e43b3c xen/drivers/passthrough/vtd/intremap.c --- a/xen/drivers/passthrough/vtd/intremap.c Thu May 05 17:40:34 2011 +0100 +++ b/xen/drivers/passthrough/vtd/intremap.c Wed May 11 12:29:54 2011 +0200 @@ -210,7 +210,8 @@ if ( iremap_entries ) unmap_vtd_domain_page(iremap_entries); =20 - ir_ctrl->iremap_num++; + if ( i < IREMAP_ENTRY_NR )=20 + ir_ctrl->iremap_num++; return i; } =20 @@ -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; } =20 @@ -281,7 +284,8 @@ if ( index < 0 ) { index =3D alloc_remap_entry(iommu); - apic_pin_2_ir_idx[apic][ioapic_pin] =3D index; + if ( index < IREMAP_ENTRY_NR ) + apic_pin_2_ir_idx[apic][ioapic_pin] =3D index; } =20 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; } =20