From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752110AbbIPAQP (ORCPT ); Tue, 15 Sep 2015 20:16:15 -0400 Received: from mail-ob0-f177.google.com ([209.85.214.177]:34695 "EHLO mail-ob0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751681AbbIPAQO (ORCPT ); Tue, 15 Sep 2015 20:16:14 -0400 Date: Wed, 16 Sep 2015 08:16:51 +0800 From: Peng Fan To: Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Frank Rowand , Grant Likely Subject: Re: [PATCH] drivers: of: check input parameter name for __of_find_property Message-ID: <20150916001650.GA28082@linux-4gyl.site> References: <1441979043-19694-1-git-send-email-van.freenix@gmail.com> <55F83FAC.5080002@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55F83FAC.5080002@kernel.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.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 > > Cc: Rob Herring > > Cc: Frank Rowand > > Cc: Grant Likely > > --- > > 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) { > > >