[patch 4/5] dmar: use list_for_each_entry_safe() in dmar_dev_scope_init()

From: Suresh Siddha
Date: Wed Sep 03 2008 - 20:10:44 EST


From: Suresh Siddha <suresh.b.siddha@xxxxxxxxx>
Subject: dmar: use list_for_each_entry_safe() in dmar_dev_scope_init()

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 <suresh.b.siddha@xxxxxxxxx>
Acked-by: Yinghai Lu <yhlu.kernel@xxxxxxxxx>
---

Index: tip/drivers/pci/dmar.c
===================================================================
--- tip.orig/drivers/pci/dmar.c 2008-09-03 14:43:02.000000000 -0700
+++ tip/drivers/pci/dmar.c 2008-09-03 14:50:15.000000000 -0700
@@ -397,10 +397,10 @@

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;
@@ -408,8 +408,8 @@

#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;

--

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/