From: Suresh Siddha Subject: dmar: use list_for_each_entry_safe() in dmar_dev_scope_init() References: fate #303948 and fate #303984 Patch-Mainline: queued for .28 Commit-ID: 228324076234ca6a8cd34be89be78022773459f1 Signed-off-by: Thomas Renninger In dmar_dev_scope_init(), functions called under for_each_drhd_unit()/ for_each_rmrr_units() can delete the list entry under some error conditions. So we should use list_for_each_entry_safe() for safe traversal. Signed-off-by: Suresh Siddha Acked-by: Yinghai Lu Signed-off-by: Ingo Molnar --- drivers/pci/dmar.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) Index: linux-2.6.26/drivers/pci/dmar.c =================================================================== --- linux-2.6.26.orig/drivers/pci/dmar.c +++ linux-2.6.26/drivers/pci/dmar.c @@ -373,10 +373,10 @@ dmar_find_matched_drhd_unit(struct pci_d int __init dmar_dev_scope_init(void) { - struct dmar_drhd_unit *drhd; + struct dmar_drhd_unit *drhd, *drhd_n; int ret = -ENODEV; - for_each_drhd_unit(drhd) { + list_for_each_entry_safe(drhd, drhd_n, &dmar_drhd_units, list) { ret = dmar_parse_dev(drhd); if (ret) return ret; @@ -384,8 +384,8 @@ int __init dmar_dev_scope_init(void) #ifdef CONFIG_DMAR { - struct dmar_rmrr_unit *rmrr; - for_each_rmrr_units(rmrr) { + struct dmar_rmrr_unit *rmrr, *rmrr_n; + list_for_each_entry_safe(rmrr, rmrr_n, &dmar_rmrr_units, list) { ret = rmrr_parse_dev(rmrr); if (ret) return ret;