Before the boot wrapper reorganization, the code checked if finddevice()
returned (void *)-1. The reorganization replaced that check with a NULL
check. Restore the (void *)-1 check so a failed lookup does not pass an
invalid handle to of_getprop().

Fixes: b2c5f61920ee ("[POWERPC] Start arch/powerpc/boot code reorganization")
Signed-off-by: Thorsten Blum <[email protected]>
---
 arch/powerpc/boot/ofconsole.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/boot/ofconsole.c b/arch/powerpc/boot/ofconsole.c
index 8eb0f1c452c5..6dbb0e46ed02 100644
--- a/arch/powerpc/boot/ofconsole.c
+++ b/arch/powerpc/boot/ofconsole.c
@@ -21,6 +21,7 @@ static int of_console_open(void)
        void *devp;
 
        if (((devp = of_finddevice("/chosen")) != NULL)
+           && (devp != (void *)-1)
            && (of_getprop(devp, "stdout", &of_stdout_handle,
                           sizeof(of_stdout_handle))
                == sizeof(of_stdout_handle))) {

Reply via email to