[PATCH] Add null pointer check to of_find_property
Paul Mackerras
paulus at samba.org
Fri May 9 14:50:19 EST 2008
Michael Ellerman writes:
> On Wed, 2008-05-07 at 14:19 -0500, Timur Tabi wrote:
> > 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.
> >
> > Signed-off-by: Timur Tabi <timur at freescale.com>
> > ---
> >
> > This patch allows callers to do this:
>
> np = of_find_compatible_node(...);
> prop = of_get_property(np);
> if (!prop)
> goto error;
>
> ...
>
> error:
> of_node_put(np)
>
> :)
And of_node_put looks like this:
void of_node_put(struct device_node *node)
{
if (node)
kref_put(&node->kref, of_node_release);
}
so it's OK.
:)
Paul.
More information about the Linuxppc-dev
mailing list