WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] RE: [Xen HV PATCH] VT-d: Fix resource leaks on error paths

To: Igor Mammedov <imammedo@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] RE: [Xen HV PATCH] VT-d: Fix resource leaks on error paths
From: "Kay, Allen M" <allen.m.kay@xxxxxxxxx>
Date: Fri, 13 May 2011 10:48:48 -0700
Accept-language: en-US
Acceptlanguage: en-US
Cc: "keir@xxxxxxx" <keir@xxxxxxx>
Delivery-date: Fri, 13 May 2011 10:49:35 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1305189007-16043-1-git-send-email-imammedo@xxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1305189007-16043-1-git-send-email-imammedo@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcwQftqHP1GPODpKQd2W01H4DcSxMwBFwfPw
Thread-topic: [Xen HV PATCH] VT-d: Fix resource leaks on error paths
Looks good to me.  ACK!

-----Original Message-----
From: Igor Mammedov [mailto:imammedo@xxxxxxxxxx] 
Sent: Thursday, May 12, 2011 1:30 AM
To: xen-devel@xxxxxxxxxxxxxxxxxxx
Cc: Kay, Allen M; keir@xxxxxxx
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 <imammedo@xxxxxxxxxx>

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);
 
-    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;
     }
 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel