Commit 72800360 authored by Alex Chiang's avatar Alex Chiang Committed by Jesse Barnes

PCI: pci_slot: grab refcount on slot's bus

If a logical hot unplug (remove) is performed on a physical PCI slot's
parent bridge, and then pci_slot is unloaded, we will encounter an oops:

  [<ffffffff803a788a>] kobject_release+0x9a/0x290
  [<ffffffff803a77f0>] ? kobject_release+0x0/0x290
  [<ffffffff803a8ce7>] kref_put+0x37/0x80
  [<ffffffff803a76f7>] kobject_put+0x27/0x60
  [<ffffffff803bebcc>] ? pci_destroy_slot+0x3c/0xc0
  [<ffffffff803bebd5>] pci_destroy_slot+0x45/0xc0
  [<ffffffffa000f05c>] acpi_pci_slot_remove+0x5c/0x91 [pci_slot]
  [<ffffffff8040064b>] acpi_pci_unregister_driver+0x4b/0x62
  [<ffffffffa000f5c8>] acpi_pci_slot_exit+0x10/0x12 [pci_slot]
  [<ffffffff80276ce1>] sys_delete_module+0x161/0x250

We need to grab a reference to the parent PCI bus, which will pin
the bus and prevent it from being released until pci_slot is unloaded.

Cc: lenb@kernel.org
Reviewed-by: default avatarKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Tested-by: default avatarKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Reported-by: default avatarKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: default avatarAlex Chiang <achiang@hp.com>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent 5d4a4b25
...@@ -164,6 +164,8 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) ...@@ -164,6 +164,8 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
list_add(&slot->list, &slot_list); list_add(&slot->list, &slot_list);
mutex_unlock(&slot_list_lock); mutex_unlock(&slot_list_lock);
get_device(&pci_bus->dev);
dbg("pci_slot: %p, pci_bus: %x, device: %d, name: %s\n", dbg("pci_slot: %p, pci_bus: %x, device: %d, name: %s\n",
pci_slot, pci_bus->number, device, name); pci_slot, pci_bus->number, device, name);
...@@ -310,12 +312,15 @@ static void ...@@ -310,12 +312,15 @@ static void
acpi_pci_slot_remove(acpi_handle handle) acpi_pci_slot_remove(acpi_handle handle)
{ {
struct acpi_pci_slot *slot, *tmp; struct acpi_pci_slot *slot, *tmp;
struct pci_bus *pbus;
mutex_lock(&slot_list_lock); mutex_lock(&slot_list_lock);
list_for_each_entry_safe(slot, tmp, &slot_list, list) { list_for_each_entry_safe(slot, tmp, &slot_list, list) {
if (slot->root_handle == handle) { if (slot->root_handle == handle) {
list_del(&slot->list); list_del(&slot->list);
pbus = slot->pci_slot->bus;
pci_destroy_slot(slot->pci_slot); pci_destroy_slot(slot->pci_slot);
put_device(&pbus->dev);
kfree(slot); kfree(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