From patchwork Tue Aug 16 18:24:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 1072182 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 p7GIeXVL016849 for ; Tue, 16 Aug 2011 18:40:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752915Ab1HPSkb (ORCPT ); Tue, 16 Aug 2011 14:40:31 -0400 Received: from smtp2.caviumnetworks.com ([209.113.159.134]:11253 "EHLO smtp2.caviumnetworks.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752904Ab1HPSk2 (ORCPT ); Tue, 16 Aug 2011 14:40:28 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 16 Aug 2011 18:40:33 +0000 (UTC) X-Greylist: delayed 922 seconds by postgrey-1.27 at vger.kernel.org; Tue, 16 Aug 2011 14:40:28 EDT Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by smtp2.caviumnetworks.com with MailMarshal (v6, 7, 2, 8378) id ; Tue, 16 Aug 2011 14:25:08 -0400 Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 16 Aug 2011 11:24:57 -0700 Received: from dd1.caveonetworks.com ([64.2.3.195]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 16 Aug 2011 11:24:57 -0700 Received: from dd1.caveonetworks.com (localhost.localdomain [127.0.0.1]) by dd1.caveonetworks.com (8.14.4/8.14.4) with ESMTP id p7GIOjJ2018490; Tue, 16 Aug 2011 11:24:51 -0700 Received: (from ddaney@localhost) by dd1.caveonetworks.com (8.14.4/8.14.4/Submit) id p7GIOfSo018489; Tue, 16 Aug 2011 11:24:41 -0700 From: David Daney To: linux-kernel@vger.kernel.org Cc: David Daney , Benjamin Herrenschmidt , Jesse Barnes , linux-pci@vger.kernel.org, Grant Likely Subject: [PATCH] pci/of: Don't crash when bridge parent is NULL. Date: Tue, 16 Aug 2011 11:24:37 -0700 Message-Id: <1313519077-18457-1-git-send-email-david.daney@cavium.com> X-Mailer: git-send-email 1.7.2.3 X-OriginalArrivalTime: 16 Aug 2011 18:24:57.0577 (UTC) FILETIME=[CD696D90:01CC5C41] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org In pcibios_get_phb_of_node(), we will crash while booting if bus->bridge->parent is NULL. Check for this case and avoid dereferencing the NULL pointer. Signed-off-by: David Daney Cc: Benjamin Herrenschmidt Cc: Jesse Barnes Cc: linux-pci@vger.kernel.org Cc: Grant Likely Acked-by: Benjamin Herrenschmidt Acked-by: Grant Likely --- drivers/pci/of.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index c94d37e..f092993 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -55,7 +55,7 @@ struct device_node * __weak pcibios_get_phb_of_node(struct pci_bus *bus) */ if (bus->bridge->of_node) return of_node_get(bus->bridge->of_node); - if (bus->bridge->parent->of_node) + if (bus->bridge->parent && bus->bridge->parent->of_node) return of_node_get(bus->bridge->parent->of_node); return NULL; }