[PATCH 3/19] ppc64: Make get_property(NULL, "foo") return NULL rather than dieing

Michael Ellerman michael at ellerman.id.au
Tue Jul 26 18:58:39 EST 2005


In prom.c get_property() will die if you pass it NULL as the node parameter.

Some code calling get_property() checks the node is non-NULL, but other code
doesn't. The neatest solution is just to make get_property(NULL, "foo")
return NULL as if the node exists but just has no "foo" property. Code that
cares about the nodes existence can check the node explicitly.

---

 arch/ppc64/kernel/prom.c |    3 +++
 1 files changed, 3 insertions(+)

Index: work/arch/ppc64/kernel/prom.c
===================================================================
--- work.orig/arch/ppc64/kernel/prom.c
+++ work/arch/ppc64/kernel/prom.c
@@ -1760,6 +1760,9 @@ get_property(struct device_node *np, con
 {
 	struct property *pp;
 
+	if (!np)
+		return NULL;
+
 	for (pp = np->properties; pp != 0; pp = pp->next)
 		if (strcmp(pp->name, name) == 0) {
 			if (lenp != 0)



More information about the Linuxppc64-dev mailing list