Re: [PATCH 4/4] pinctrl: nomadik: Prevent NULL dereference if of_match_device returns NULL

2012-11-15 Thread Lee Jones
On Thu, 15 Nov 2012, Linus Walleij wrote:

> On Thu, Nov 15, 2012 at 5:56 AM, Axel Lin  wrote:
> 
> > of_match_device() may return NULL.
> >
> > Signed-off-by: Axel Lin 
> > ---
> >  drivers/pinctrl/pinctrl-nomadik.c |   11 ---
> >  1 file changed, 8 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/pinctrl/pinctrl-nomadik.c 
> > b/drivers/pinctrl/pinctrl-nomadik.c
> > index 238060e..40bd1b3 100644
> > --- a/drivers/pinctrl/pinctrl-nomadik.c
> > +++ b/drivers/pinctrl/pinctrl-nomadik.c
> > @@ -1863,9 +1863,14 @@ static int __devinit nmk_pinctrl_probe(struct 
> > platform_device *pdev)
> >
> > if (platid)
> > version = platid->driver_data;
> > -   else if (np)
> > -   version = (unsigned int)
> > -   of_match_device(nmk_pinctrl_match, 
> > >dev)->data;
> > +   else if (np) {
> > +   const struct of_device_id *match;
> > +
> > +   match = of_match_device(nmk_pinctrl_match, >dev);
> > +   if (!match)
> > +   return -ENODEV;
> > +   version = (unsigned int) match->data;
> > +   }
> 
> AFAICT this can actually happen so patch applied, unless Lee
> speaks against it.

At the very least it make the code easy to read.

Acked-by: Lee Jones 

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 4/4] pinctrl: nomadik: Prevent NULL dereference if of_match_device returns NULL

2012-11-15 Thread Linus Walleij
On Thu, Nov 15, 2012 at 5:56 AM, Axel Lin  wrote:

> of_match_device() may return NULL.
>
> Signed-off-by: Axel Lin 
> ---
>  drivers/pinctrl/pinctrl-nomadik.c |   11 ---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-nomadik.c 
> b/drivers/pinctrl/pinctrl-nomadik.c
> index 238060e..40bd1b3 100644
> --- a/drivers/pinctrl/pinctrl-nomadik.c
> +++ b/drivers/pinctrl/pinctrl-nomadik.c
> @@ -1863,9 +1863,14 @@ static int __devinit nmk_pinctrl_probe(struct 
> platform_device *pdev)
>
> if (platid)
> version = platid->driver_data;
> -   else if (np)
> -   version = (unsigned int)
> -   of_match_device(nmk_pinctrl_match, >dev)->data;
> +   else if (np) {
> +   const struct of_device_id *match;
> +
> +   match = of_match_device(nmk_pinctrl_match, >dev);
> +   if (!match)
> +   return -ENODEV;
> +   version = (unsigned int) match->data;
> +   }

AFAICT this can actually happen so patch applied, unless Lee
speaks against it.

Patches 1-3/4 are dropped though, as the maintainers didn't seem
to like them.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 4/4] pinctrl: nomadik: Prevent NULL dereference if of_match_device returns NULL

2012-11-15 Thread Linus Walleij
On Thu, Nov 15, 2012 at 5:56 AM, Axel Lin axel@ingics.com wrote:

 of_match_device() may return NULL.

 Signed-off-by: Axel Lin axel@ingics.com
 ---
  drivers/pinctrl/pinctrl-nomadik.c |   11 ---
  1 file changed, 8 insertions(+), 3 deletions(-)

 diff --git a/drivers/pinctrl/pinctrl-nomadik.c 
 b/drivers/pinctrl/pinctrl-nomadik.c
 index 238060e..40bd1b3 100644
 --- a/drivers/pinctrl/pinctrl-nomadik.c
 +++ b/drivers/pinctrl/pinctrl-nomadik.c
 @@ -1863,9 +1863,14 @@ static int __devinit nmk_pinctrl_probe(struct 
 platform_device *pdev)

 if (platid)
 version = platid-driver_data;
 -   else if (np)
 -   version = (unsigned int)
 -   of_match_device(nmk_pinctrl_match, pdev-dev)-data;
 +   else if (np) {
 +   const struct of_device_id *match;
 +
 +   match = of_match_device(nmk_pinctrl_match, pdev-dev);
 +   if (!match)
 +   return -ENODEV;
 +   version = (unsigned int) match-data;
 +   }

AFAICT this can actually happen so patch applied, unless Lee
speaks against it.

Patches 1-3/4 are dropped though, as the maintainers didn't seem
to like them.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 4/4] pinctrl: nomadik: Prevent NULL dereference if of_match_device returns NULL

2012-11-15 Thread Lee Jones
On Thu, 15 Nov 2012, Linus Walleij wrote:

 On Thu, Nov 15, 2012 at 5:56 AM, Axel Lin axel@ingics.com wrote:
 
  of_match_device() may return NULL.
 
  Signed-off-by: Axel Lin axel@ingics.com
  ---
   drivers/pinctrl/pinctrl-nomadik.c |   11 ---
   1 file changed, 8 insertions(+), 3 deletions(-)
 
  diff --git a/drivers/pinctrl/pinctrl-nomadik.c 
  b/drivers/pinctrl/pinctrl-nomadik.c
  index 238060e..40bd1b3 100644
  --- a/drivers/pinctrl/pinctrl-nomadik.c
  +++ b/drivers/pinctrl/pinctrl-nomadik.c
  @@ -1863,9 +1863,14 @@ static int __devinit nmk_pinctrl_probe(struct 
  platform_device *pdev)
 
  if (platid)
  version = platid-driver_data;
  -   else if (np)
  -   version = (unsigned int)
  -   of_match_device(nmk_pinctrl_match, 
  pdev-dev)-data;
  +   else if (np) {
  +   const struct of_device_id *match;
  +
  +   match = of_match_device(nmk_pinctrl_match, pdev-dev);
  +   if (!match)
  +   return -ENODEV;
  +   version = (unsigned int) match-data;
  +   }
 
 AFAICT this can actually happen so patch applied, unless Lee
 speaks against it.

At the very least it make the code easy to read.

Acked-by: Lee Jones lee.jo...@linaro.org

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/