From patchwork Wed Jul 22 01:14:14 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kenji Kaneshige X-Patchwork-Id: 36664 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 n6M1DEMt024851 for ; Wed, 22 Jul 2009 01:14:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751993AbZGVBOd (ORCPT ); Tue, 21 Jul 2009 21:14:33 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752437AbZGVBOd (ORCPT ); Tue, 21 Jul 2009 21:14:33 -0400 Received: from fgwmail7.fujitsu.co.jp ([192.51.44.37]:38045 "EHLO fgwmail7.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751993AbZGVBOc (ORCPT ); Tue, 21 Jul 2009 21:14:32 -0400 Received: from m2.gw.fujitsu.co.jp ([10.0.50.72]) by fgwmail7.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id n6M1EWWu008211 for (envelope-from kaneshige.kenji@jp.fujitsu.com); Wed, 22 Jul 2009 10:14:32 +0900 Received: from smail (m2 [127.0.0.1]) by outgoing.m2.gw.fujitsu.co.jp (Postfix) with ESMTP id DC58C45DE55 for ; Wed, 22 Jul 2009 10:14:31 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (s2.gw.fujitsu.co.jp [10.0.50.92]) by m2.gw.fujitsu.co.jp (Postfix) with ESMTP id 8F85E45DE51 for ; Wed, 22 Jul 2009 10:14:31 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 4423EE38002 for ; Wed, 22 Jul 2009 10:14:31 +0900 (JST) Received: from ml14.s.css.fujitsu.com (ml14.s.css.fujitsu.com [10.249.87.104]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id BC910E78008 for ; Wed, 22 Jul 2009 10:14:30 +0900 (JST) Received: from ml14.css.fujitsu.com (ml14 [127.0.0.1]) by ml14.s.css.fujitsu.com (Postfix) with ESMTP id 9364F9F6213; Wed, 22 Jul 2009 10:14:30 +0900 (JST) Received: from [127.0.0.1] (unknown [10.124.100.137]) by ml14.s.css.fujitsu.com (Postfix) with ESMTP id 2B0009F6212; Wed, 22 Jul 2009 10:14:30 +0900 (JST) X-SecurityPolicyCheck-FJ: OK by FujitsuOutboundMailChecker v1.3.1 Received: from KANE-LIFEBOOK[10.124.100.137] by KANE-LIFEBOOK (FujitsuOutboundMailChecker v1.3.1/9992[10.124.100.137]); Wed, 22 Jul 2009 10:14:19 +0900 (JST) Message-ID: <4A6667E6.60206@jp.fujitsu.com> Date: Wed, 22 Jul 2009 10:14:14 +0900 From: Kenji Kaneshige User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 To: Jesse Barnes , "Li, Shaohua" , "linux-pci@vger.kernel.org" Subject: [PATCH 3/7] PCI ASPM: fix possible null pointer dereference References: <4A66673A.2070409@jp.fujitsu.com> In-Reply-To: <4A66673A.2070409@jp.fujitsu.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Fix possible NULL dereference in pcie_aspm_exit_link_state(). This patch also cleanup some code. Signed-off-by: Kenji Kaneshige --- drivers/pci/pcie/aspm.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 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: 20090721/drivers/pci/pcie/aspm.c =================================================================== --- 20090721.orig/drivers/pci/pcie/aspm.c +++ 20090721/drivers/pci/pcie/aspm.c @@ -665,16 +665,16 @@ out: void pcie_aspm_exit_link_state(struct pci_dev *pdev) { struct pci_dev *parent = pdev->bus->self; - struct pcie_link_state *link_state = parent->link_state; + struct pcie_link_state *link; - if (aspm_disabled || !pdev->is_pcie || !parent || !link_state) + if (aspm_disabled || !pdev->is_pcie || !parent || !parent->link_state) return; if (parent->pcie_type != PCI_EXP_TYPE_ROOT_PORT && - parent->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) + parent->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) return; + down_read(&pci_bus_sem); mutex_lock(&aspm_lock); - /* * All PCIe functions are in one slot, remove one function will remove * the whole slot, so just wait until we are the last function left. @@ -682,13 +682,14 @@ void pcie_aspm_exit_link_state(struct pc if (!list_is_last(&pdev->bus_list, &parent->subordinate->devices)) goto out; + link = parent->link_state; + /* All functions are removed, so just disable ASPM for the link */ __pcie_aspm_config_one_dev(parent, 0); - list_del(&link_state->sibling); - list_del(&link_state->link); + list_del(&link->sibling); + list_del(&link->link); /* Clock PM is for endpoint device */ - - free_link_state(link_state); + free_link_state(link); out: mutex_unlock(&aspm_lock); up_read(&pci_bus_sem);