diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2013-07-14 23:03:14 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2013-08-14 00:58:27 -0400 |
commit | 2db29d28eb100e464cfaf1a2146d0bf58198212d (patch) | |
tree | 9166c28c6353e87fe8fca69915d2828779c1b81b | |
parent | e0f5fa99a378d6910d234f3c8998aebfe2f54745 (diff) |
powerpc/powernv: Don't crash if there are no OPAL consoles
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>
-rw-r--r-- | arch/powerpc/platforms/powernv/opal.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c index 7c253469f23b..2911abe550f1 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) | |||
380 | pr_warn("opal: Node not found\n"); | 380 | pr_warn("opal: Node not found\n"); |
381 | return -ENODEV; | 381 | return -ENODEV; |
382 | } | 382 | } |
383 | |||
384 | /* Register OPAL consoles if any ports */ | ||
383 | if (firmware_has_feature(FW_FEATURE_OPALv2)) | 385 | if (firmware_has_feature(FW_FEATURE_OPALv2)) |
384 | consoles = of_find_node_by_path("/ibm,opal/consoles"); | 386 | consoles = of_find_node_by_path("/ibm,opal/consoles"); |
385 | else | 387 | else |
386 | consoles = of_node_get(opal_node); | 388 | consoles = of_node_get(opal_node); |
387 | 389 | if (consoles) { | |
388 | /* Register serial ports */ | 390 | for_each_child_of_node(consoles, np) { |
389 | for_each_child_of_node(consoles, np) { | 391 | if (strcmp(np->name, "serial")) |
390 | if (strcmp(np->name, "serial")) | 392 | continue; |
391 | continue; | 393 | of_platform_device_create(np, NULL, NULL); |
392 | of_platform_device_create(np, NULL, NULL); | 394 | } |
395 | of_node_put(consoles); | ||
393 | } | 396 | } |
394 | of_node_put(consoles); | ||
395 | 397 | ||
396 | /* Find all OPAL interrupts and request them */ | 398 | /* Find all OPAL interrupts and request them */ |
397 | irqs = of_get_property(opal_node, "opal-interrupts", &irqlen); | 399 | irqs = of_get_property(opal_node, "opal-interrupts", &irqlen); |