linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: linuxppc-dev@ozlabs.org
Subject: [PATCH 7/8] powerpc/powernv: Don't crash if there are no OPAL consoles
Date: Mon, 15 Jul 2013 13:03:14 +1000	[thread overview]
Message-ID: <1373857395-2084-7-git-send-email-benh@kernel.crashing.org> (raw)
In-Reply-To: <1373857395-2084-1-git-send-email-benh@kernel.crashing.org>

Some machines might provide the console via a different mechanism
such as direct access to a UART from Linux, in which case OPAL
might not expose any console. In that case, the code would cause
a NULL dereference.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 arch/powerpc/platforms/powernv/opal.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index 106301f..91cf97d 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -380,18 +380,20 @@ static int __init opal_init(void)
 		pr_warn("opal: Node not found\n");
 		return -ENODEV;
 	}
+
+	/* Register OPAL consoles if any ports */
 	if (firmware_has_feature(FW_FEATURE_OPALv2))
 		consoles = of_find_node_by_path("/ibm,opal/consoles");
 	else
 		consoles = of_node_get(opal_node);
-
-	/* Register serial ports */
-	for_each_child_of_node(consoles, np) {
-		if (strcmp(np->name, "serial"))
-			continue;
-		of_platform_device_create(np, NULL, NULL);
+	if (consoles) {
+		for_each_child_of_node(consoles, np) {
+			if (strcmp(np->name, "serial"))
+				continue;
+			of_platform_device_create(np, NULL, NULL);
+		}
+		of_node_put(consoles);
 	}
-	of_node_put(consoles);
 
 	/* Find all OPAL interrupts and request them */
 	irqs = of_get_property(opal_node, "opal-interrupts", &irqlen);
-- 
1.8.1.2

  parent reply	other threads:[~2013-07-15  3:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-15  3:03 [PATCH 1/8] powerpc: Better split CONFIG_PPC_INDIRECT_PIO and CONFIG_PPC_INDIRECT_MMIO Benjamin Herrenschmidt
2013-07-15  3:03 ` [PATCH 2/8] powerpc/powernv: Update opal.h to add new LPC and XSCOM functions Benjamin Herrenschmidt
2013-07-15  3:03 ` [PATCH 3/8] powerpc/powernv: Add helper to get ibm,chip-id of a node Benjamin Herrenschmidt
2013-07-15  3:03 ` [PATCH 4/8] powerpc/powernv: Add PIO accessors for Power8 LPC bus Benjamin Herrenschmidt
2013-07-15  3:03 ` [PATCH 5/8] powerpc: Cleanup udbg_16550 and add support for LPC PIO-only UARTs Benjamin Herrenschmidt
2013-07-15  3:03 ` [PATCH 6/8] powerpc: Check "status" property before adding legacy ISA serial ports Benjamin Herrenschmidt
2013-07-15  3:03 ` Benjamin Herrenschmidt [this message]
2013-07-15  3:03 ` [PATCH 8/8] powerpc/powernv: Enable detection of legacy UARTs Benjamin Herrenschmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1373857395-2084-7-git-send-email-benh@kernel.crashing.org \
    --to=benh@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).