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

Anatolij Gustschin agust at denx.de
Sun Jan 12 20:51:01 CET 2020


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


More information about the U-Boot mailing list