Re: [PATCH] PCI fixes for 2.6.9

From: Greg KH
Date: Tue Oct 19 2004 - 18:47:34 EST


ChangeSet 1.1997.2.122, 2004/10/15 12:00:07-07:00, johnrose@xxxxxxxxxxxxxx

[PATCH] PCI Hotplug: rpaphp safe list traversal

Hoping you will accept this fix. The bug can cause a crash upon hotplug
remove. The bug involves unsafe traversal of a list while deleting list
members. The fix uses list_for_each_safe() rather than
list_for_each(). Also threw in an initialization to get rid of a
compiler warning.

Signed-off-by: John Rose <johnrose@xxxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <greg@xxxxxxxxx>


drivers/pci/hotplug/rpaphp_pci.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)


diff -Nru a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
--- a/drivers/pci/hotplug/rpaphp_pci.c 2004-10-19 15:21:10 -07:00
+++ b/drivers/pci/hotplug/rpaphp_pci.c 2004-10-19 15:21:10 -07:00
@@ -118,7 +118,7 @@
{
int state, rc;
struct device_node *child_dn;
- struct pci_dev *child_dev;
+ struct pci_dev *child_dev = NULL;

*value = NOT_VALID;
rc = rpaphp_get_sensor_state(slot, &state);
@@ -369,7 +369,7 @@
int rpaphp_unconfig_pci_adapter(struct slot *slot)
{
int retval = 0;
- struct list_head *ln;
+ struct list_head *ln, *tmp;

dbg("Entry %s: slot[%s]\n", __FUNCTION__, slot->name);
if (list_empty(&slot->dev.pci_funcs)) {
@@ -380,7 +380,7 @@
goto exit;
}
/* remove the devices from the pci core */
- list_for_each (ln, &slot->dev.pci_funcs) {
+ list_for_each_safe (ln, tmp, &slot->dev.pci_funcs) {
struct rpaphp_pci_func *func;

func = list_entry(ln, struct rpaphp_pci_func, sibling);

-
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/