iommu/vt-d: Remove BUG_ON in dmar_insert_dev_scope()
authorTina Zhang <tina.zhang@intel.com>
Thu, 13 Apr 2023 04:06:45 +0000 (12:06 +0800)
committerJoerg Roedel <jroedel@suse.de>
Thu, 13 Apr 2023 10:05:53 +0000 (12:05 +0200)
The dmar_insert_dev_scope() could fail if any unexpected condition is
encountered. However, in this situation, the kernel should attempt
recovery and proceed with execution. Remove BUG_ON with WARN_ON, so that
kernel can avoid being crashed when an unexpected condition occurs.

Signed-off-by: Tina Zhang <tina.zhang@intel.com>
Link: https://lore.kernel.org/r/20230406065944.2773296-8-tina.zhang@intel.com
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/intel/dmar.c

index 9684c96..7eceee0 100644 (file)
@@ -262,7 +262,8 @@ int dmar_insert_dev_scope(struct dmar_pci_notify_info *info,
                                                   get_device(dev));
                                return 1;
                        }
-               BUG_ON(i >= devices_cnt);
+               if (WARN_ON(i >= devices_cnt))
+                       return -EINVAL;
        }
 
        return 0;