From patchwork Wed Aug 31 05:00:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Iyer X-Patchwork-Id: 1115002 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 p7V4wvWV020048 for ; Wed, 31 Aug 2011 05:00:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752665Ab1HaFA1 (ORCPT ); Wed, 31 Aug 2011 01:00:27 -0400 Received: from mail-vw0-f46.google.com ([209.85.212.46]:41204 "EHLO mail-vw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751366Ab1HaFA1 (ORCPT ); Wed, 31 Aug 2011 01:00:27 -0400 Received: by vws1 with SMTP id 1so294110vws.19 for ; Tue, 30 Aug 2011 22:00:26 -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=tKfNE3Ilzj4j59ErGIC5qbiFObNzrTZbMKexcScknYkTkM5db8ASJ2IwsovwrIywGH aYmZQ95Hz1fCsOOx/MZE3/UA2Ak/EWRDLjuhcnRA9HdqRmHEipUUrknXtFHjHpyBAbeq eNEB2IGkbhBfNNXSbVUOSuG6r5XRlzf/OBM9U= Received: by 10.52.35.142 with SMTP id h14mr2584747vdj.374.1314766826707; Tue, 30 Aug 2011 22:00:26 -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 cg6sm4129732vdc.41.2011.08.30.22.00.25 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 30 Aug 2011 22:00:25 -0700 (PDT) From: Shyam Iyer To: linux-pci@vger.kernel.org Cc: sgruszka@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 01:00:20 -0400 Message-Id: <1314766820-27345-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 05:00:28 +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;