* [PATCH] drivers: of: check input parameter name for __of_find_property
@ 2015-09-11 13:44 ` Peng Fan
0 siblings, 0 replies; 7+ messages in thread
From: Peng Fan @ 2015-09-11 13:44 UTC (permalink / raw)
To: robh+dt; +Cc: devicetree, van.freenix, linux-kernel, Frank Rowand, Grant Likely
Check input parameter 'name' for __of_find_property. If name is NULL,
of_prop_cmp->strcasecmp may trigger panic.
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) {
--
1.8.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] drivers: of: check input parameter name for __of_find_property
@ 2015-09-11 13:44 ` Peng Fan
0 siblings, 0 replies; 7+ messages in thread
From: Peng Fan @ 2015-09-11 13:44 UTC (permalink / raw)
To: robh+dt-DgEjT+Ai2ygdnm+yROfE0A
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
van.freenix-Re5JQEeQqe8AvxtiuMwx3w,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Frank Rowand, Grant Likely
Check input parameter 'name' for __of_find_property. If name is NULL,
of_prop_cmp->strcasecmp may trigger panic.
Signed-off-by: Peng Fan <van.freenix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Frank Rowand <frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Grant Likely <grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.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) {
--
1.8.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] drivers: of: check input parameter name for __of_find_property
2015-09-11 13:44 ` Peng Fan
(?)
@ 2015-09-15 15:56 ` Rob Herring
2015-09-16 0:16 ` Peng Fan
-1 siblings, 1 reply; 7+ messages in thread
From: Rob Herring @ 2015-09-15 15:56 UTC (permalink / raw)
To: Peng Fan; +Cc: devicetree, linux-kernel, Frank Rowand, Grant Likely
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?
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) {
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drivers: of: check input parameter name for __of_find_property
2015-09-15 15:56 ` Rob Herring
@ 2015-09-16 0:16 ` Peng Fan
2015-09-16 2:27 ` Rob Herring
0 siblings, 1 reply; 7+ messages in thread
From: Peng Fan @ 2015-09-16 0:16 UTC (permalink / raw)
To: Rob Herring; +Cc: devicetree, linux-kernel, Frank Rowand, Grant Likely
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) {
> >
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drivers: of: check input parameter name for __of_find_property
@ 2015-09-16 2:27 ` Rob Herring
0 siblings, 0 replies; 7+ messages in thread
From: Rob Herring @ 2015-09-16 2:27 UTC (permalink / raw)
To: Peng Fan; +Cc: devicetree, linux-kernel, Frank Rowand, Grant Likely
On 09/15/2015 07:16 PM, Peng Fan wrote:
> 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.
propname will only be NULL if the memory allocation failed which gives
you a big warning message. I don't think you would want to continue on
in this case.
So I'm inclined to leave this as is with passing NULL to
of_find_property to always be an error and fatal.
Rob
> 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) {
>>>
>>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drivers: of: check input parameter name for __of_find_property
@ 2015-09-16 2:27 ` Rob Herring
0 siblings, 0 replies; 7+ messages in thread
From: Rob Herring @ 2015-09-16 2:27 UTC (permalink / raw)
To: Peng Fan
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Frank Rowand, Grant Likely
On 09/15/2015 07:16 PM, Peng Fan wrote:
> 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.
propname will only be NULL if the memory allocation failed which gives
you a big warning message. I don't think you would want to continue on
in this case.
So I'm inclined to leave this as is with passing NULL to
of_find_property to always be an error and fatal.
Rob
> 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>> Cc: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
>>> Cc: Frank Rowand <frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>> Cc: Grant Likely <grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.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) {
>>>
>>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drivers: of: check input parameter name for __of_find_property
2015-09-16 2:27 ` Rob Herring
(?)
@ 2015-09-16 13:55 ` Peng Fan
-1 siblings, 0 replies; 7+ messages in thread
From: Peng Fan @ 2015-09-16 13:55 UTC (permalink / raw)
To: Rob Herring; +Cc: devicetree, linux-kernel, Frank Rowand, Grant Likely
On Tue, Sep 15, 2015 at 09:27:59PM -0500, Rob Herring wrote:
> On 09/15/2015 07:16 PM, Peng Fan wrote:
> > 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.
>
> propname will only be NULL if the memory allocation failed which gives
> you a big warning message. I don't think you would want to continue on
> in this case.
>
> So I'm inclined to leave this as is with passing NULL to
> of_find_property to always be an error and fatal.
of_find_property has EXPORT_SYMBOL, it maybe called in different places. And it should handle the case that name is NULL, right?
If passing NULL to of_find_property is an error, then why check parameter 'np' like "if (!np)" in of_find_property?
Regards,
Peng.
>
> Rob
>
> > 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) {
> >>>
> >>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-09-16 13:55 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-11 13:44 [PATCH] drivers: of: check input parameter name for __of_find_property Peng Fan
2015-09-11 13:44 ` Peng Fan
2015-09-15 15:56 ` Rob Herring
2015-09-16 0:16 ` Peng Fan
2015-09-16 2:27 ` Rob Herring
2015-09-16 2:27 ` Rob Herring
2015-09-16 13:55 ` Peng Fan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.