public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pci/of: Don't crash when bridge parent is NULL.
@ 2011-08-16 18:24 David Daney
  2011-08-16 19:16 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 4+ messages in thread
From: David Daney @ 2011-08-16 18:24 UTC (permalink / raw)
  To: linux-kernel
  Cc: David Daney, Benjamin Herrenschmidt, Jesse Barnes, linux-pci,
	Grant Likely

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 <david.daney@cavium.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: linux-pci@vger.kernel.org
Cc: Grant Likely <grant.likely@secretlab.ca>
---
 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;
 }
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-08-17 11:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-16 18:24 [PATCH] pci/of: Don't crash when bridge parent is NULL David Daney
2011-08-16 19:16 ` Benjamin Herrenschmidt
2011-08-17  4:11   ` Jesse Barnes
2011-08-17 11:29     ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox