From patchwork Mon Mar 30 16:50:19 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Chiang X-Patchwork-Id: 15161 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2UGsDGg018391 for ; Mon, 30 Mar 2009 16:54:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756579AbZC3QuZ (ORCPT ); Mon, 30 Mar 2009 12:50:25 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756701AbZC3QuY (ORCPT ); Mon, 30 Mar 2009 12:50:24 -0400 Received: from g1t0027.austin.hp.com ([15.216.28.34]:10342 "EHLO g1t0027.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756394AbZC3QuU (ORCPT ); Mon, 30 Mar 2009 12:50:20 -0400 Received: from smtp1.fc.hp.com (smtp.cnd.hp.com [15.15.136.127]) by g1t0027.austin.hp.com (Postfix) with ESMTP id 814AC38422; Mon, 30 Mar 2009 16:50:19 +0000 (UTC) Received: from localhost.localdomain (lart.fc.hp.com [15.11.146.31]) by smtp1.fc.hp.com (Postfix) with ESMTP id D0A942435B2; Mon, 30 Mar 2009 16:20:54 +0000 (UTC) Received: from bob.kio (localhost [127.0.0.1]) by localhost.localdomain (Postfix) with ESMTP id 4807826143; Mon, 30 Mar 2009 10:50:19 -0600 (MDT) Subject: [PATCH v2 3/3] PCI: pci_slot: grab refcount on slot's bus To: jbarnes@virtuousgeek.org From: Alex Chiang Cc: linux-pci@vger.kernel.org, Kenji Kaneshige , linux-kernel@vger.kernel.org, lenb@kernel.org Date: Mon, 30 Mar 2009 10:50:19 -0600 Message-ID: <20090330165019.18855.69386.stgit@bob.kio> In-Reply-To: <20090330164737.18855.7137.stgit@bob.kio> References: <20090330164737.18855.7137.stgit@bob.kio> User-Agent: StGit/0.14.3.347.g594a MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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: [] kobject_release+0x9a/0x290 [] ? kobject_release+0x0/0x290 [] kref_put+0x37/0x80 [] kobject_put+0x27/0x60 [] ? pci_destroy_slot+0x3c/0xc0 [] pci_destroy_slot+0x45/0xc0 [] acpi_pci_slot_remove+0x5c/0x91 [pci_slot] [] acpi_pci_unregister_driver+0x4b/0x62 [] acpi_pci_slot_exit+0x10/0x12 [pci_slot] [] 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 Reported-by: Kenji Kaneshige Signed-off-by: Alex Chiang Reviewed-by: Kenji Kaneshige Tested-by: Kenji Kaneshige --- drivers/acpi/pci_slot.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c index cd1f446..12158e0 100644 --- a/drivers/acpi/pci_slot.c +++ b/drivers/acpi/pci_slot.c @@ -164,6 +164,8 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) list_add(&slot->list, &slot_list); mutex_unlock(&slot_list_lock); + get_device(&pci_bus->dev); + dbg("pci_slot: %p, pci_bus: %x, device: %d, name: %s\n", pci_slot, pci_bus->number, device, name); @@ -310,12 +312,15 @@ static void acpi_pci_slot_remove(acpi_handle handle) { struct acpi_pci_slot *slot, *tmp; + struct pci_bus *pbus; mutex_lock(&slot_list_lock); list_for_each_entry_safe(slot, tmp, &slot_list, list) { if (slot->root_handle == handle) { list_del(&slot->list); + pbus = slot->pci_slot->bus; pci_destroy_slot(slot->pci_slot); + put_device(&pbus->dev); kfree(slot); } }