From patchwork Fri Jan 10 07:50:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Delaunay X-Patchwork-Id: 239372 List-Id: U-Boot discussion From: patrick.delaunay at st.com (Patrick Delaunay) Date: Fri, 10 Jan 2020 08:50:31 +0100 Subject: [PATCH] tools: ftdgrep: correct the find regions loop in do_fdtgrep Message-ID: <20200110085027.1.I4a80e4d2935f07164868f198fe868a0999be777e@changeid> Update the loop executed in do_fdtgrep to find all the regions and add a test for count > max_region only when the second passes is executed. This patch solve an issue if the number of region found (count) is greater then the default value (max_region = count = 100): the second pass is never executed, because the loop stops after the first pass (i = 0, count > 100, max_regions = 100) with error -1 and the error message "Internal error with fdtgrep_find_region". I also update the error message. Signed-off-by: Patrick Delaunay --- tools/fdtgrep.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); - fprintf(stderr, "Internal error with fdtgrep_find_region)(\n"); + fprintf(stderr, "Internal error with fdtgrep_find_region()\n"); return -1; }