From patchwork Fri Aug 10 06:12:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taku Izumi X-Patchwork-Id: 1304131 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 05CB53FC66 for ; Fri, 10 Aug 2012 06:12:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753023Ab2HJGMe (ORCPT ); Fri, 10 Aug 2012 02:12:34 -0400 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:51458 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752849Ab2HJGMd (ORCPT ); Fri, 10 Aug 2012 02:12:33 -0400 Received: from m1.gw.fujitsu.co.jp (unknown [10.0.50.71]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id C0F7B3EE0BB; Fri, 10 Aug 2012 15:12:32 +0900 (JST) Received: from smail (m1 [127.0.0.1]) by outgoing.m1.gw.fujitsu.co.jp (Postfix) with ESMTP id A7F7345DE58; Fri, 10 Aug 2012 15:12:32 +0900 (JST) Received: from s1.gw.fujitsu.co.jp (s1.gw.fujitsu.co.jp [10.0.50.91]) by m1.gw.fujitsu.co.jp (Postfix) with ESMTP id 9375E45DE56; Fri, 10 Aug 2012 15:12:32 +0900 (JST) Received: from s1.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s1.gw.fujitsu.co.jp (Postfix) with ESMTP id 87BEBE38001; Fri, 10 Aug 2012 15:12:32 +0900 (JST) Received: from m001.s.css.fujitsu.com (m001.s.css.fujitsu.com [10.23.4.39]) by s1.gw.fujitsu.co.jp (Postfix) with ESMTP id 46A401DB8045; Fri, 10 Aug 2012 15:12:32 +0900 (JST) Received: from m001.css.fujitsu.com (m001 [127.0.0.1]) by m001.s.css.fujitsu.com (Postfix) with ESMTP id 334C950EC9C; Fri, 10 Aug 2012 15:12:30 +0900 (JST) Received: from DEUCALION (unknown [10.124.101.32]) by m001.s.css.fujitsu.com (Postfix) with SMTP id A238750ECA5; Fri, 10 Aug 2012 15:12:29 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v1.7.4 Date: Fri, 10 Aug 2012 15:12:27 +0900 From: Taku Izumi To: Taku Izumi Cc: linux-pci@vger.kernel.org, bhelgaas@google.com, linux-acpi@vger.kernel.org, kaneshige.kenji@jp.fujitsu.com, yinghai@kernel.org, jiang.liu@huawei.com Subject: [PATCH 2/7][RESEND] PCI: Correctly clean up pci root buses in function pci_remove_bus() Message-Id: <20120810151227.cc02c783.izumi.taku@jp.fujitsu.com> In-Reply-To: <20120810150955.e4ab3c7f.izumi.taku@jp.fujitsu.com> References: <20120810150955.e4ab3c7f.izumi.taku@jp.fujitsu.com> X-Mailer: Sylpheed 3.1.1 (GTK+ 2.10.14; i686-pc-mingw32) Mime-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Jiang Liu Correctly clean up pci root buses in function pci_remove_bus() The function pci_create_root_bus() allocates the pci bus structure, registers the bus device and creates the legacy files for a pci root bus, but returns without setting the is_added flag. The is_added flag for a pci root bus will be set by function pci_scan_child_bus(). If a pci root bus is destroyed before calling pci_scan_child_bus(), the is_added flag will not be set. So teach function pci_remove_bus() to detect such a case and correctly clean up pci root buses. Signed-off-by: Jiang Liu Signed-off-by: Yinghai Lu Signed-off-by: Taku Izumi --- drivers/pci/remove.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 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 Index: Bjorn-next-0808/drivers/pci/remove.c =================================================================== --- Bjorn-next-0808.orig/drivers/pci/remove.c +++ Bjorn-next-0808/drivers/pci/remove.c @@ -70,11 +70,10 @@ void pci_remove_bus(struct pci_bus *pci_ list_del(&pci_bus->node); pci_bus_release_busn_res(pci_bus); up_write(&pci_bus_sem); - if (!pci_bus->is_added) - return; - - pci_remove_legacy_files(pci_bus); - device_unregister(&pci_bus->dev); + if (pci_bus->is_added || pci_is_root_bus(pci_bus)) { + pci_remove_legacy_files(pci_bus); + device_unregister(&pci_bus->dev); + } } EXPORT_SYMBOL(pci_remove_bus);