devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Cc: Nicolas Iooss <nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>,
	Jon Loeliger <jdl-CYoMK+44s/E@public.gmane.org>,
	Devicetree Compiler
	<devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH 3/5] tests: Make realloc_fdt() really allocate *fdt
Date: Thu, 9 Mar 2017 12:35:53 +1100	[thread overview]
Message-ID: <20170309013553.GN19967@umbus.fritz.box> (raw)
In-Reply-To: <CAPnjgZ0=jfYeYZSZUeQRf00wyHaQwDBRYvqAQqO6Bu0B2VA5NA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 1836 bytes --]

On Wed, Mar 08, 2017 at 02:01:47PM -0700, Simon Glass wrote:
> On 4 March 2017 at 06:26, Nicolas Iooss <nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org> wrote:
> > This bug has been found by using clang Static Analyzer: it reported that
> > the value stored to fdt was never read.
> >
> > Signed-off-by: Nicolas Iooss <nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
> > ---
> >  tests/sw_tree1.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> Reviewed-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> 
> I suggest changing the code in main() so it starts with a 0 size. Then
> the test would catch this problem.

Ah, yes, I was going to suggest this when I reviewed the series, but
then I forgot.

> 
> >
> > diff --git a/tests/sw_tree1.c b/tests/sw_tree1.c
> > index 6d4c53102967..4887dc3e1172 100644
> > --- a/tests/sw_tree1.c
> > +++ b/tests/sw_tree1.c
> > @@ -42,14 +42,14 @@ static void realloc_fdt(void **fdt, size_t *size, bool created)
> >         switch (alloc_mode) {
> >         case FIXED:
> >                 if (!(*fdt))
> > -                       fdt = xmalloc(*size);
> > +                       *fdt = xmalloc(*size);
> >                 else
> >                         FAIL("Ran out of space");
> >                 return;
> >
> >         case RESIZE:
> >                 if (!(*fdt)) {
> > -                       fdt = xmalloc(SPACE);
> > +                       *fdt = xmalloc(SPACE);
> >                 } else if (*size < SPACE) {
> >                         *size += 1;
> >                         fdt_resize(*fdt, *fdt, *size);
> >

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2017-03-09  1:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-04 13:26 [PATCH 1/5] dtc: Simplify asm_emit_string() implementation Nicolas Iooss
     [not found] ` <20170304132647.23286-1-nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
2017-03-04 13:26   ` [PATCH 2/5] libfdt: overlay: Check the value of the right variable Nicolas Iooss
     [not found]     ` <20170304132647.23286-2-nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
2017-03-08 21:01       ` Simon Glass
     [not found]         ` <CAPnjgZ2Lon3e-NV-FH76QpXFP2tAcc=Ex48hG7OMQxbcjzBfig-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-09  1:35           ` David Gibson
2017-03-04 13:26   ` [PATCH 3/5] tests: Make realloc_fdt() really allocate *fdt Nicolas Iooss
     [not found]     ` <20170304132647.23286-3-nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
2017-03-08 21:01       ` Simon Glass
     [not found]         ` <CAPnjgZ0=jfYeYZSZUeQRf00wyHaQwDBRYvqAQqO6Bu0B2VA5NA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-09  1:35           ` David Gibson [this message]
2017-03-04 13:26   ` [PATCH 4/5] fdtget: Use @return to document the return value Nicolas Iooss
     [not found]     ` <20170304132647.23286-4-nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
2017-03-08 21:01       ` Simon Glass
2017-03-04 13:26   ` [PATCH 5/5] fdtput: Remove star from value_len documentation Nicolas Iooss
     [not found]     ` <20170304132647.23286-5-nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
2017-03-08 21:01       ` Simon Glass
2017-03-06  4:13   ` [PATCH 1/5] dtc: Simplify asm_emit_string() implementation David Gibson

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=20170309013553.GN19967@umbus.fritz.box \
    --to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
    --cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=jdl-CYoMK+44s/E@public.gmane.org \
    --cc=nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org \
    --cc=sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.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).