From patchwork Wed Jul 4 08:07:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taku Izumi X-Patchwork-Id: 1154791 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 5A14CDFF0F for ; Wed, 4 Jul 2012 08:07:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933382Ab2GDIHR (ORCPT ); Wed, 4 Jul 2012 04:07:17 -0400 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:40058 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932166Ab2GDIHO (ORCPT ); Wed, 4 Jul 2012 04:07:14 -0400 Received: from m3.gw.fujitsu.co.jp (unknown [10.0.50.73]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id 2CD263EE0BB for ; Wed, 4 Jul 2012 17:07:13 +0900 (JST) Received: from smail (m3 [127.0.0.1]) by outgoing.m3.gw.fujitsu.co.jp (Postfix) with ESMTP id D2AD245DEAD for ; Wed, 4 Jul 2012 17:07:12 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (s3.gw.fujitsu.co.jp [10.0.50.93]) by m3.gw.fujitsu.co.jp (Postfix) with ESMTP id BBC6C45DE7E for ; Wed, 4 Jul 2012 17:07:12 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id AC3E61DB803E for ; Wed, 4 Jul 2012 17:07:12 +0900 (JST) Received: from m0001.s.css.fujitsu.com (m0001.s.css.fujitsu.com [10.23.4.186]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id 69253E18001 for ; Wed, 4 Jul 2012 17:07:12 +0900 (JST) Received: from m0001.css.fujitsu.com (m0001 [127.0.0.1]) by m0001.s.css.fujitsu.com (Postfix) with ESMTP id 5A7A610176E; Wed, 4 Jul 2012 17:07:12 +0900 (JST) Received: from DEUCALION (unknown [10.124.101.32]) by m0001.s.css.fujitsu.com (Postfix) with SMTP id 3BAA31013C8; Wed, 4 Jul 2012 17:07:12 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v1.7.4 Date: Wed, 4 Jul 2012 17:07:07 +0900 From: Taku Izumi To: Taku Izumi Cc: linux-pci@vger.kernel.org, Bjorn Helgaas , Kenji Kaneshige , Yinghai Lu , Jiang Liu Subject: [PATCH 2/7] PCI: Correctly clean up pci root buses in function pci_remove_bus() Message-Id: <20120704170707.9303dc62.izumi.taku@jp.fujitsu.com> In-Reply-To: <20120704170345.07cd0ad7.izumi.taku@jp.fujitsu.com> References: <20120704170345.07cd0ad7.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 --- 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: linux/drivers/pci/remove.c =================================================================== --- linux.orig/drivers/pci/remove.c 2012-07-04 09:54:52.126485695 +0900 +++ linux/drivers/pci/remove.c 2012-07-04 09:55:33.695965952 +0900 @@ -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);