ChangeSet 1.1587.12.88, 2004/05/11 14:50:01-07:00, eike-hotplug@sf-tec.de [PATCH] SHPC PCI Hotplug: fix cleanup_slots again... Am Donnerstag, 6. Mai 2004 02:48 schrieb Sy, Dely L: > On Fri, 30 Apr 2004 12:31:18 +0200, Rolf Eike Beer wrote: >> - >> -static int cleanup_slots (struct controller * ctrl) >> +static void cleanup_slots(const struct controller *ctrl) >> { >> - struct slot *old_slot, *next_slot; >> + struct slot *old_slot; >> >> old_slot = ctrl->slot; >> ctrl->slot = NULL; >> >> while (old_slot) { >> - next_slot = old_slot->next; >> - pci_hp_deregister (old_slot->hotplug_slot); >> - kfree(old_slot->hotplug_slot->info); >> - kfree(old_slot->hotplug_slot->name); >> - kfree(old_slot->hotplug_slot); >> - kfree(old_slot); >> - old_slot = next_slot; >> + pci_hp_deregister(old_slot->hotplug_slot); >> + old_slot = old_slot->next; >> } > > The variable next_slot and its assignment should be kept, for once > pci_hp_deregister() is called and the release callback function, which > you added, may come in and clean up old_slot structure before the next > ptr is saved. The code should be: > > static void cleanup_slots(const struct controller *ctrl) > { > struct slot *old_slot, *next_slot; > > old_slot = ctrl->slot; > ctrl->slot = NULL; > > while (old_slot) { > next_slot = old_slot->next; > pci_hp_deregister (old_slot->hotplug_slot); > old_slot = next_slot; > } > } Yes, good point. Greg, this patch makes does it. Please apply on top of the other stuff. drivers/pci/hotplug/shpchp_core.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff -Nru a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c --- a/drivers/pci/hotplug/shpchp_core.c Mon May 17 16:57:01 2004 +++ b/drivers/pci/hotplug/shpchp_core.c Mon May 17 16:57:01 2004 @@ -195,14 +195,15 @@ static void cleanup_slots(struct controller *ctrl) { - struct slot *old_slot; + struct slot *old_slot, *next_slot; old_slot = ctrl->slot; ctrl->slot = NULL; while (old_slot) { + next_slot = old_slot->next; pci_hp_deregister(old_slot->hotplug_slot); - old_slot = old_slot->next; + old_slot = next_slot; } }