File 26578-AMD-IOMMU-replace-BUG_ON.patch of Package xen.openSUSE_12.1_Update

# HG changeset patch
# User Jan Beulich <jbeulich@suse.com>
# Date 1361176655 -3600
# Node ID 57e67af5281a6b66cf71dfa812e4335930684fd6
# Parent  45d59b822ed187c535b127679e32853b148ed411
AMD IOMMU: don't BUG() when we don't have to

find_iommu_for_device() can easily return NULL instead, as all of its
callers are prepared for that.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c
@@ -30,8 +30,7 @@ extern struct ivrs_mappings *ivrs_mappin
 
 struct amd_iommu *find_iommu_for_device(int bdf)
 {
-    BUG_ON ( bdf >= ivrs_bdf_entries );
-    return ivrs_mappings[bdf].iommu;
+    return bdf < ivrs_bdf_entries ? ivrs_mappings[bdf].iommu : NULL;
 }
 
 /*
openSUSE Build Service is sponsored by