From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anatolij Gustschin Date: Sun, 12 Jan 2020 20:51:01 +0100 Subject: [PATCH] tools: ftdgrep: correct the find regions loop in do_fdtgrep In-Reply-To: <20200110085027.1.I4a80e4d2935f07164868f198fe868a0999be777e@changeid> References: <20200110085027.1.I4a80e4d2935f07164868f198fe868a0999be777e@changeid> Message-ID: <20200112205101.669fe9d3@crub> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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)); -- Anatolij