From: "Grant Likely" <grant.likely@secretlab.ca>
To: "Timur Tabi" <timur@freescale.com>
Cc: linuxppc-dev@ozlabs.org, paulus@samba.org
Subject: Re: [PATCH] Add null pointer check to of_find_property
Date: Wed, 7 May 2008 13:27:28 -0600 [thread overview]
Message-ID: <fa686aa40805071227q11a9462fvc99945c725e945c0@mail.gmail.com> (raw)
In-Reply-To: <1210187999-20274-1-git-send-email-timur@freescale.com>
On Wed, May 7, 2008 at 1:19 PM, Timur Tabi <timur@freescale.com> 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@freescale.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
> ---
>
> This patch allows callers to do this:
>
> np = of_find_compatible_node(...);
> prop = of_get_property(np);
> if (!prop)
> goto error;
>
> Today, we need a np==NULL check between the two of_ calls. Some callers may
> not care whether the node is missing or the property is missing.
>
> drivers/of/base.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 9bd7c4a..23ffb7c 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -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) {
> --
> 1.5.5
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
>
--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
next prev parent reply other threads:[~2008-05-07 19:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-07 19:19 [PATCH] Add null pointer check to of_find_property Timur Tabi
2008-05-07 19:27 ` Grant Likely [this message]
2008-05-07 23:21 ` Michael Ellerman
2008-05-09 4:50 ` Paul Mackerras
2008-05-12 16:46 ` Timur Tabi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fa686aa40805071227q11a9462fvc99945c725e945c0@mail.gmail.com \
--to=grant.likely@secretlab.ca \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.org \
--cc=timur@freescale.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).