From patchwork Wed Aug 31 04:58:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Iyer X-Patchwork-Id: 1114982 X-Patchwork-Delegate: bhelgaas@google.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7V4wvWT020048 for ; Wed, 31 Aug 2011 04:58:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752946Ab1HaE6o (ORCPT ); Wed, 31 Aug 2011 00:58:44 -0400 Received: from mail-qy0-f181.google.com ([209.85.216.181]:46311 "EHLO mail-qy0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753034Ab1HaE6n (ORCPT ); Wed, 31 Aug 2011 00:58:43 -0400 Received: by qyk34 with SMTP id 34so219854qyk.19 for ; Tue, 30 Aug 2011 21:58:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=W9HvDjnLEiVI36jBf8TRs2sx4OAUZxfU+ZrTWns4zxk=; b=kFdEwN6eT3i+Pvo6wpvpHedy9alF40LTTktWuRzL9JRJgXffxqX9W6xXywVGBUZkVo IINcjziicQLOeSfDHXGq9Nh0BxLWI0VWH6HdQEDEkZT9Ctj6Ecr2+khm02FJPrRlExET PQlQyle+lXvAmCB1VJNI+PaiS32eTHbQMbMtA= Received: by 10.224.218.129 with SMTP id hq1mr3622753qab.282.1314766722483; Tue, 30 Aug 2011 21:58:42 -0700 (PDT) Received: from localhost.localdomain (c-66-31-66-120.hsd1.nh.comcast.net. [66.31.66.120]) by mx.google.com with ESMTPS id cb17sm7536099qab.4.2011.08.30.21.58.41 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 30 Aug 2011 21:58:41 -0700 (PDT) From: Shyam Iyer To: linux-pci@vger.kernel.org Cc: sgruzka@redhat.com, mason@myri.com, jbarnes@virtuousgeek.org, Shyam Iyer Subject: [PATCH] [pci] Fix pointer dereference before call to pcie_bus_configure_settings Date: Wed, 31 Aug 2011 00:58:35 -0400 Message-Id: <1314766715-27286-1-git-send-email-shyam_iyer@dell.com> X-Mailer: git-send-email 1.7.2.3 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 31 Aug 2011 04:58:58 +0000 (UTC) Commit b03e7495a862b028294f59fc87286d6d78ee7fa1 introduces a few issues by dereferencing bus->self in the call to pcie_bus_configure_settings. This fixes it by checking existence of bus->self before dereferencing it. Reported-by: Stanislaw Gruszka Signed-off-by: Shyam Iyer --- arch/x86/pci/acpi.c | 8 ++++++-- drivers/pci/hotplug/pcihp_slot.c | 3 ++- drivers/pci/probe.c | 3 --- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index c953302..a11b673 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c @@ -365,8 +365,12 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root) */ if (bus) { struct pci_bus *child; - list_for_each_entry(child, &bus->children, node) - pcie_bus_configure_settings(child, child->self->pcie_mpss); + list_for_each_entry(child, &bus->children, node) { + if (child->self) + pcie_bus_configure_settings(child, + child->self->\ + pcie_mpss); + } } if (!bus) diff --git a/drivers/pci/hotplug/pcihp_slot.c b/drivers/pci/hotplug/pcihp_slot.c index 753b21a..ef5596d 100644 --- a/drivers/pci/hotplug/pcihp_slot.c +++ b/drivers/pci/hotplug/pcihp_slot.c @@ -169,7 +169,8 @@ void pci_configure_slot(struct pci_dev *dev) (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI))) return; - pcie_bus_configure_settings(dev->bus, dev->bus->self->pcie_mpss); + if (dev->bus && dev->bus->self) + pcie_bus_configure_settings(dev->bus, dev->bus->self->pcie_mpss); memset(&hpp, 0, sizeof(hpp)); ret = pci_get_hp_params(dev, &hpp); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 8473727..0820fc1 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1456,9 +1456,6 @@ void pcie_bus_configure_settings(struct pci_bus *bus, u8 mpss) { u8 smpss = mpss; - if (!bus->self) - return; - if (!pci_is_pcie(bus->self)) return;