From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751896Ab1HPTRK (ORCPT ); Tue, 16 Aug 2011 15:17:10 -0400 Received: from gate.crashing.org ([63.228.1.57]:44470 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751043Ab1HPTRI (ORCPT ); Tue, 16 Aug 2011 15:17:08 -0400 Subject: Re: [PATCH] pci/of: Don't crash when bridge parent is NULL. From: Benjamin Herrenschmidt To: David Daney Cc: linux-kernel@vger.kernel.org, Jesse Barnes , linux-pci@vger.kernel.org, Grant Likely In-Reply-To: <1313519077-18457-1-git-send-email-david.daney@cavium.com> References: <1313519077-18457-1-git-send-email-david.daney@cavium.com> Content-Type: text/plain; charset="UTF-8" Date: Tue, 16 Aug 2011 14:16:18 -0500 Message-ID: <1313522178.3664.69.camel@pasglop> Mime-Version: 1.0 X-Mailer: Evolution 2.32.2 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2011-08-16 at 11:24 -0700, David Daney wrote: > 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 Acked-by: Benjamin Herrenschmidt Jesse or Grant, I'm travelling, can any of you send that to Linus asap ? Cheers, Ben. > Cc: Jesse Barnes > Cc: linux-pci@vger.kernel.org > Cc: 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; > }