Commit 08c7b59b authored by Rolf Eike Beer's avatar Rolf Eike Beer Committed by Deepak Saxena

[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.
parent 3476911c
......@@ -195,14 +195,15 @@ static int init_slots(struct controller *ctrl)
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;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment