powerpc/sysdev/ipic: check primary_ipic NULL pointer before using it
authorChristophe Leroy <christophe.leroy@c-s.fr>
Mon, 27 Aug 2018 08:27:27 +0000 (08:27 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Sat, 20 Oct 2018 02:26:47 +0000 (13:26 +1100)
ipic_get_mcp_status() is used by targets implementing NMI
watchdog in target specific machine check handler in order
to known whether a machine check results from a watchdog
NMI reset.

In case of very early machine check, primary_ipic pointer
might not have been set yet, so ipic_get_mcp_status() needs
to check it for nullity before using it.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/sysdev/ipic.c

index 535cf1f6941c01fd1b2b70b7e630cf2f8fea0e64..6300123ce96536a915d59fb30eac0438df2b4efa 100644 (file)
@@ -846,7 +846,7 @@ void ipic_disable_mcp(enum ipic_mcp_irq mcp_irq)
 
 u32 ipic_get_mcp_status(void)
 {
-       return ipic_read(primary_ipic->regs, IPIC_SERSR);
+       return primary_ipic ? ipic_read(primary_ipic->regs, IPIC_SERSR) : 0;
 }
 
 void ipic_clear_mcp_status(u32 mask)