vtd: Fix some dmar bugs
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 29 Jul 2008 09:41:41 +0000 (10:41 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 29 Jul 2008 09:41:41 +0000 (10:41 +0100)
In acpi_parse_one_drhd(), remove return directly when only one
INCLUDE_ALL check fails, so that avoid memory leak. In addition,
remove "dmaru->scope.devices_cnt == 0 && !dmaru->include_all" check,
due to PCI-PCI bridges are not counted.

This patch fixes bug #1307.

Signed-off-by: Weidong Han <weidong.han@intel.com>
xen/drivers/passthrough/vtd/dmar.c

index eb73a04ce5b938796fbe073ceb43e6e9c0be14c5..4b83510131a92cca5f0f11670f06c2892c5b927e 100644 (file)
@@ -238,15 +238,15 @@ static int __init acpi_parse_dev_scope(void *start, void *end,
             bus = pci_conf_read8(bus, path->dev, path->fn, PCI_SECONDARY_BUS);
             path++;
         }
-        
+
         switch ( acpi_scope->dev_type )
         {
         case ACPI_DEV_P2PBRIDGE:
         {
             sec_bus = pci_conf_read8(
-               bus, path->dev, path->fn, PCI_SECONDARY_BUS);
+                bus, path->dev, path->fn, PCI_SECONDARY_BUS);
             sub_bus = pci_conf_read8(
-               bus, path->dev, path->fn, PCI_SUBORDINATE_BUS);
+                bus, path->dev, path->fn, PCI_SUBORDINATE_BUS);
             dprintk(XENLOG_INFO VTDPREFIX,
                     "found bridge: bdf = %x:%x.%x  sec = %x  sub = %x\n",
                     bus, path->dev, path->fn, sec_bus, sub_bus);
@@ -328,13 +328,13 @@ acpi_parse_one_drhd(struct acpi_dmar_entry_header *header)
         if ( include_all )
         {
             dprintk(XENLOG_WARNING VTDPREFIX,
-                    "Onlyu onw INCLUDE_ALL device scope is allowed\n");
-            return -EINVAL;
+                    "Only one INCLUDE_ALL device scope is allowed\n");
+            ret = -EINVAL;
         }
         include_all = 1;
     }
 
-    if ( ret || (dmaru->scope.devices_cnt == 0 && !dmaru->include_all) )
+    if ( ret )
         xfree(dmaru);
     else
         acpi_register_drhd_unit(dmaru);
@@ -396,7 +396,8 @@ acpi_parse_one_atsr(struct acpi_dmar_entry_header *header)
         ret = acpi_parse_dev_scope(dev_scope_start, dev_scope_end,
                                    atsru, ATSR_TYPE);
     }
-    else {
+    else
+    {
         dprintk(XENLOG_INFO VTDPREFIX, "found ALL_PORTS\n");
         /* Only allow one ALL_PORTS */
         if ( all_ports )