mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Masahiro Yamada <yamada.m@jp.panasonic.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2] param: add error check to __dev_add_param()
Date: Thu, 29 Jan 2015 19:51:15 +0900	[thread overview]
Message-ID: <20150129195115.3DB2.AA925319@jp.panasonic.com> (raw)
In-Reply-To: <20150129090622.GZ12209@pengutronix.de>

Hi Sascha,



On Thu, 29 Jan 2015 10:06:22 +0100
Sascha Hauer <s.hauer@pengutronix.de> wrote:

> Besides, I normally don't like these checks. dereferencing NULL pointers
> means you get a backtrace showing you what went wrong. Returning an error
> means adding code which in this case makes dev_add_param just fail
> silently because the return value often is not checked.
> 

What a coincidence!
Actually, I was writing the following patch yesterday:




> Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
> Date:   Wed Jan 28 22:07:59 2015 +0900
> 
>     param: do not search NULL-named parameter
>     
>     If the argument name is given with NULL, it is passed to strcmp()
>     resulting in NULL-pointer access.  It would be safer to return NULL
>     (which means "Not found") in such a case.
>     
>     Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
> 
> diff --git a/lib/parameter.c b/lib/parameter.c
> index 865ad9f..c37d877 100644
> --- a/lib/parameter.c
> +++ b/lib/parameter.c
> @@ -33,6 +33,9 @@ struct param_d *get_param_by_name(struct device_d *dev, const char *name)
>  {
>         struct param_d *p;
>  
> +       if (!name)
> +               return NULL;
> +
>         list_for_each_entry(p, &dev->parameters, list) {
>                 if (!strcmp(p->name, name))
>                         return p;


Do you mean, you do not like such a patch?



Best Regards
Masahiro Yamada


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2015-01-29 10:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-29  2:46 Masahiro Yamada
2015-01-29  9:06 ` Sascha Hauer
2015-01-29  9:21   ` Masahiro Yamada
2015-01-29  9:32     ` Sascha Hauer
2015-01-29 10:47       ` Masahiro Yamada
2015-01-30  7:44         ` Sascha Hauer
2015-01-29 10:51   ` Masahiro Yamada [this message]

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=20150129195115.3DB2.AA925319@jp.panasonic.com \
    --to=yamada.m@jp.panasonic.com \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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