All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc: Add missing error check to prom_find_boot_cpu()
@ 2017-01-23 19:42 Darren Stevens
  2017-01-27  0:33 ` Michael Ellerman
  0 siblings, 1 reply; 3+ messages in thread
From: Darren Stevens @ 2017-01-23 19:42 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Christian Zigotzky, rtd, Pat Wall, aperez

[-- Attachment #1: Type: text/plain, Size: 178 bytes --]

  AmigaOS...........: http://yam.ch/
  Unix/MacOS/Windows: http://www.mozilla.com/thunderbird/

General information about MIME can be found at:
http://en.wikipedia.org/wiki/MIME

[-- Attachment #2: Type: text/plain, Size: 657 bytes --]

prom_init.c calls 'instance-to-package' twice, but the return
is not checked during prom_find_boot_cpu(). The result is then
passed to prom_getprop, which could be PROM_ERROR.
Add a return check to prevent this.

This was found on a pasemi system, where CFE doesn't have a working
'instance-to package' prom call.
Before Commit 5c0484e25ec0 ('powerpc: Endian safe trampoline') the
area around addr 0 as mostly 0's and this doesn't cause a problem.
Once the macro 'FIXUP_ENDIAN' has been added to head_64.S, the low
memory area now has non-zero values, which cause the prom_getprop
call to hang.

Signed-off-by: Darren Stevens <darren@stevens-zone.net>

---

[-- Attachment #3: prom_init.patch --]
[-- Type: text/plain, Size: 448 bytes --]

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index ec47a93..ac83eb0 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -2834,6 +2834,9 @@ static void __init prom_find_boot_cpu(void)
 
 	cpu_pkg = call_prom("instance-to-package", 1, 1, prom_cpu);
 
+	if (!PHANDLE_VALID(cpu_pkg))
+		return;
+
 	prom_getprop(cpu_pkg, "reg", &rval, sizeof(rval));
 	prom.cpu = be32_to_cpu(rval);
 

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

end of thread, other threads:[~2017-01-27 13:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-23 19:42 [PATCH] powerpc: Add missing error check to prom_find_boot_cpu() Darren Stevens
2017-01-27  0:33 ` Michael Ellerman
2017-01-27 13:05   ` Darren Stevens

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.