Skip to content

Commit

Permalink
[POWERPC] Add null pointer check to of_find_property
Browse files Browse the repository at this point in the history
Update function of_find_property() to return NULL if the device_node
passed to it is also NULL.  Otherwise, passing NULL will cause a null
pointer dereference.

Without this, the legacy_serial driver will crash if there's no
'chosen' node in the device tree.

Signed-off-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Timur Tabi authored and Paul Mackerras committed May 15, 2008
1 parent cec08e7 commit 64e4566
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/of/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ struct property *of_find_property(const struct device_node *np,
{
struct property *pp;

if (!np)
return NULL;

read_lock(&devtree_lock);
for (pp = np->properties; pp != 0; pp = pp->next) {
if (of_prop_cmp(pp->name, name) == 0) {
Expand Down

0 comments on commit 64e4566

Please sign in to comment.