[PATCH 3/7] powerpc: null pointer check

Dave C Boutcher sleddog at us.ibm.com
Thu Jan 12 12:27:55 EST 2006


There should never be a device-tree node without a name
property.  But if one ever shows up, the panic is not
pretty.  Add a quick check to make the name pointer
is not null before we use it.

Signed-off-by: Dave Boutcher <sledog at us.ibm.com>

diff -uNr linux-2.6.15-patched/arch/powerpc/kernel/prom.c linux-2.6.15-patched2/arch/powerpc/kernel/prom.c
--- linux-2.6.15-patched/arch/powerpc/kernel/prom.c	2006-01-11 17:46:57.000000000 -0600
+++ linux-2.6.15-patched2/arch/powerpc/kernel/prom.c	2006-01-11 17:54:10.000000000 -0600
@@ -613,7 +613,8 @@
 	if (ip != NULL)
 		nsizec = *ip;
 
-	if (!strcmp(np->name, "device-tree") || np->parent == NULL)
+	if ((np->name && !strcmp(np->name, "device-tree"))
+	    || (np->parent == NULL))
 		ifunc = interpret_root_props;
 	else if (np->type == 0)
 		ifunc = NULL;

-- 
Dave Boutcher



More information about the Linuxppc64-dev mailing list