[PATCH] tools: ftdgrep: correct the find regions loop in do_fdtgrep

Patrick DELAUNAY patrick.delaunay at st.com
Mon Jan 13 09:24:35 CET 2020


Hi,

> From: Anatolij Gustschin <agust at denx.de>
> Sent: dimanche 12 janvier 2020 20:51
> 
> Hi Patrick,
> 
> On Fri, 10 Jan 2020 08:50:31 +0100
> Patrick Delaunay patrick.delaunay at st.com wrote:
> ...
> > diff --git a/tools/fdtgrep.c b/tools/fdtgrep.c index
> > 8f44f599c1..bcf06b871d 100644
> > --- a/tools/fdtgrep.c
> > +++ b/tools/fdtgrep.c
> > @@ -823,8 +823,10 @@ static int do_fdtgrep(struct display_info *disp, const
> char *filename)
> >  		}
> >  		if (count <= max_regions)
> >  			break;
> > +	}
> > +	if (count > max_regions) {
> >  		free(region);
> 
> This change moved free(region) out of the loop. If you do so, then please also
> change malloc() in the loop to realloc():
> 
> 	region = realloc(region, count * sizeof(struct fdt_region));

Yes, I will push V2 with realloc to avoid the memory leak that I introduced..

Thanks for review 

> --
> Anatolij

Patrick


More information about the U-Boot mailing list