Commit e3bbd7e4 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] PCI Hotplug: acpiphp: add release() callback

parent 5eca6bec
...@@ -379,6 +379,25 @@ static void make_slot_name (struct slot *slot) ...@@ -379,6 +379,25 @@ static void make_slot_name (struct slot *slot)
slot->acpi_slot->sun); slot->acpi_slot->sun);
} }
/**
* release_slot - free up the memory used by a slot
* @hotplug_slot: slot to free
*/
static void release_slot(struct hotplug_slot *hotplug_slot)
{
struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
if (slot == NULL)
return;
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
kfree(slot->hotplug_slot->info);
kfree(slot->hotplug_slot->name);
kfree(slot->hotplug_slot);
kfree(slot);
}
/** /**
* init_slots - initialize 'struct slot' structures for each slot * init_slots - initialize 'struct slot' structures for each slot
* *
...@@ -422,6 +441,7 @@ static int init_slots (void) ...@@ -422,6 +441,7 @@ static int init_slots (void)
slot->number = i; slot->number = i;
slot->hotplug_slot->private = slot; slot->hotplug_slot->private = slot;
slot->hotplug_slot->release = &release_slots;
slot->hotplug_slot->ops = &acpi_hotplug_slot_ops; slot->hotplug_slot->ops = &acpi_hotplug_slot_ops;
slot->acpi_slot = get_slot_from_id(i); slot->acpi_slot = get_slot_from_id(i);
...@@ -435,10 +455,7 @@ static int init_slots (void) ...@@ -435,10 +455,7 @@ static int init_slots (void)
retval = pci_hp_register(slot->hotplug_slot); retval = pci_hp_register(slot->hotplug_slot);
if (retval) { if (retval) {
err("pci_hp_register failed with error %d\n", retval); err("pci_hp_register failed with error %d\n", retval);
kfree(slot->hotplug_slot->info); release_slot();
kfree(slot->hotplug_slot->name);
kfree(slot->hotplug_slot);
kfree(slot);
return retval; return retval;
} }
...@@ -457,13 +474,10 @@ static void cleanup_slots (void) ...@@ -457,13 +474,10 @@ static void cleanup_slots (void)
struct slot *slot; struct slot *slot;
list_for_each_safe (tmp, n, &slot_list) { list_for_each_safe (tmp, n, &slot_list) {
/* memory will be freed in release_slot callback */
slot = list_entry(tmp, struct slot, slot_list); slot = list_entry(tmp, struct slot, slot_list);
list_del(&slot->slot_list); list_del(&slot->slot_list);
pci_hp_deregister(slot->hotplug_slot); pci_hp_deregister(slot->hotplug_slot);
kfree(slot->hotplug_slot->info);
kfree(slot->hotplug_slot->name);
kfree(slot->hotplug_slot);
kfree(slot);
} }
return; return;
......
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