devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peng Fan <van.freenix@gmail.com>
To: Rob Herring <robh@kernel.org>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	Frank Rowand <frowand.list@gmail.com>,
	Grant Likely <grant.likely@linaro.org>
Subject: Re: [PATCH] drivers: of: check input parameter name for __of_find_property
Date: Wed, 16 Sep 2015 08:16:51 +0800	[thread overview]
Message-ID: <20150916001650.GA28082@linux-4gyl.site> (raw)
In-Reply-To: <55F83FAC.5080002@kernel.org>

Hi Rob,

On Tue, Sep 15, 2015 at 10:56:28AM -0500, Rob Herring wrote:
> On 09/11/2015 08:44 AM, Peng Fan wrote:
> > Check input parameter 'name' for __of_find_property. If name is NULL,
> > of_prop_cmp->strcasecmp may trigger panic.
> 
> Arguably that could be a feature. Do you have a usecase where name being
> NULL is valid and panicking is a problem?

In drivers/pinctrl/devicetree.c

195                 propname = kasprintf(GFP_KERNEL, "pinctrl-%d", state);
196                 prop = of_find_property(np, propname, &size);
197                 kfree(propname);
198                 if (!prop)
199                         break;

If propname is NULL, of_find_property may trigger panic. Anyway propname should be checked
before passing to of_find_property.

I did not met panic message. I wrote this patch when I was reading the piece code.
I think the name parameter should be checked before doing string compare.

Regards,
Peng.

> 
> Rob
> 
> > 
> > Signed-off-by: Peng Fan <van.freenix@gmail.com>
> > Cc: Rob Herring <robh+dt@kernel.org>
> > Cc: Frank Rowand <frowand.list@gmail.com>
> > Cc: Grant Likely <grant.likely@linaro.org>
> > ---
> >  drivers/of/base.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/of/base.c b/drivers/of/base.c
> > index 8b5a187..e41436d 100644
> > --- a/drivers/of/base.c
> > +++ b/drivers/of/base.c
> > @@ -215,7 +215,7 @@ static struct property *__of_find_property(const struct device_node *np,
> >  {
> >  	struct property *pp;
> >  
> > -	if (!np)
> > +	if (!np || !name)
> >  		return NULL;
> >  
> >  	for (pp = np->properties; pp; pp = pp->next) {
> > 
> 

  reply	other threads:[~2015-09-16  0:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-11 13:44 [PATCH] drivers: of: check input parameter name for __of_find_property Peng Fan
2015-09-15 15:56 ` Rob Herring
2015-09-16  0:16   ` Peng Fan [this message]
     [not found]     ` <20150916001650.GA28082-12w76u+6CWdQVMFFLWfSwA@public.gmane.org>
2015-09-16  2:27       ` Rob Herring
2015-09-16 13:55         ` Peng Fan

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=20150916001650.GA28082@linux-4gyl.site \
    --to=van.freenix@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=grant.likely@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    /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).